Skip to content Skip to sidebar Skip to footer

Killing All Threads And The Process From A Thread Of The Same Process

I have a process which spawns 2 types of thread classes. One thread is responsible for consuming a job_queue (100Threads of this class are usually running). And second thread is a

Solution 1:

To avoid waiting maxtimeout time, you could use Event.wait() method:

defrun(self):
    whilenot self.result_done.is_set():
        try:
            val = self.job_queue.get_nowait()
        except Empty:
            if self.result_done.wait(1): # wait a second to avoid busy loopreturn

Event.wait(timeout) returns without waiting the full timeout if the event is set during the call.

Post a Comment for "Killing All Threads And The Process From A Thread Of The Same Process"