fork, threads and proper closing
Olivier.Darge at gmail.com
Mon Jun 29 07:10:07 CEST 2009
On 28 juin, 23:26, Tomasz Pajor <ni... at puffy.pl> wrote:
> Configuration is as follows.
> I have a starter process which creates 3 sub processes (forks) and each
> of this processes creates a number of threads.
> Threads in that processes have semaphore so on KeyboardInterrupt without
> sending a sigterm to the subprocess i'm not able to close threads.
> Is there any work around? Can I somehow run join for the thread on
> keyboard interrupt?
When creating a thread you can add a Queue parameter to communicate
easy and reliable.
give them a "poison pill" in the queue: a recognizable object placed
on the queue that means "when you get this, stop."
better to not rely on keyboard for thread stopping.
More information about the Python-list