fork, threads and proper closing

Tomasz Pajor nikon at puffy.pl
Mon Jun 29 02:22:06 EDT 2009


> On 28 juin, 23:26, Tomasz Pajor <ni... at puffy.pl> wrote:
>   
>> Hello,
>>
>> 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
> with threads:
> http://docs.python.org/library/queue.html
> 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."
>   
can You provide any working example?
> better to not rely on keyboard for thread stopping.
>   
i use keyboard interrupt only for debuging purposes
> Olivier
>   




More information about the Python-list mailing list