sockets,threads and interupts

loial jldunn2000 at gmail.com
Tue Sep 4 11:26:21 EDT 2012


I have threaded python script that uses sockets to monitor network ports.

I want to ensure that the socket is closed cleanly in all circumstances. This includes if the script is killed or interupted in some other way.

As I understand it signal only works in the main thread, so how can I trap interupts in my threaded class and always ensure I close the socket? Using KeyboardInterupt does not seem to work.





More information about the Python-list mailing list