Clean Exit from Socket/Program

Thomas Jensen spam at ob_scure.dk
Mon Jul 8 19:11:09 EDT 2002


Larry wrote:

> Can anyone give me some tips on...
> 1. How to shut down a python program cleanly

You can catch ctrl-c by catching the KeyboardError exception, like this:
try:
     ... do something ...
except KeyboardInterrupt:
     ... cleanup ...

> 2. How to ensure that my socket buffer is empty before closing.

Don't know about that one.

-- 
Best Regards
Thomas Jensen
(remove underscore in email address to mail me)




More information about the Python-list mailing list