Skip to content
Advertisement

Tag: multiprocessing

Python: will a thread ever unblock while hanging on a `Queue.get(block=True)` call if the queue is suddenly destroyed from another thread/process?

TLDR: Would a blocking get be unblocked by a queue that would be terminated in some way? Long question: Okay, so I know that the thread will hang if the queue (multiprocessing.Queue) remains empty forever while trying to fetch something from it with a blocking get. But suppose now that in another thread or process, I close the queue with

Optimal way to use multiprocessing for many files

So I have a large list of files that need to be processed into CSVs. Each file itself is quite large, and each line is a string. Each line of the files could represent one of three types of data, each of which is processed a bit differently. My current solution looks like the following: I iterate through the files,

How to do a race between multiprocessors in python

I have a function that factor a number. It depends on some random condition. So what I am trying to do it’s to run multiple processors in this function and the processor that finds the factor first returns the value and all processors terminate. What I have so far is very wrong. The processors are not terminating and I also

How to close all the processes one by one in a program that operates with multiprocessing by means of an ‘if’ validation found in one of them process?

I need that when the variable text is equal to “Close your program” the 3 active processes(p1,p2,p3) are closed. I have tried to do something like this: But it is not working for me, and I would need a better code that allows me to close them one by one in that code block if text is equal to “Close

Advertisement