Terminating a Python program that uses multi-process, multi-threading

Jesse Noller jnoller at gmail.com
Thu Jan 29 15:26:23 CET 2009

On Wed, Jan 28, 2009 at 3:46 PM, akineko <akineko at gmail.com> wrote:
> Hello Python experts,
> I have a program that uses three processes (invoked by
> multiprocessing) and several threads.
> The program is terminated when ^C is typed (KeyboardInterrupt).
> The main process takes the KeyboardInterrupt Exception and it orderly
> shutdown the program.
> It works fine in normal situation.
> However, KeyboardInterrupt is not accepted when, for example, the
> program is stuck somewhere due to error in network. I understand that
> the KeyboardInterrupt won't be processed until the program moves out
> from an atomic step in a Python program.
> Probably this is partly my fault as I use some blocking statements
> (without timeout) as they should not block the program in normal
> situation.
> As the program freezes up, I cannot do anything except killing three
> processes using kill command.
> So, I cannot tell which statement is actually blocking when this
> occurs (and there are many suspects).
> Is there any good way to deal with this kind of problem?
> Killing three processes when it hangs is not a fun thing to do.
> Any suggestions will be greatly appreciated.
> Best regards,
> Aki Niimura
> --
> http://mail.python.org/mailman/listinfo/python-list

See also:


More information about the Python-list mailing list