global exception catching
Duncan Booth
duncan at NOSPAMrcp.co.uk
Thu Feb 27 05:44:51 EST 2003
Rene Pijlman <reageer.in at de.nieuwsgroep> wrote in
news:denr5vcdd4jf31v1ad6tmpoodrc673t81b at 4ax.com:
> Brrr... Wouldn't it be better to simply remove the Break key
> from the keyboard? :-)
>
Possibly, but I hit this problem recently when I wanted a program acting as
an XMLRPC server to do some tidying up when it was closed. Windows also
generates SIGBREAK if you close the command window containing the Python
script, so it is worth handling.
The problem with sockets is that SIGBREAK doesn't get generated if your
main thread is in the middle of a system call until the call returns. Since
reading from a socket might never return (or might have a long timeout),
you have to make sure you never make long blocking calls from the main
thread (SIGBREAK always gets handled in the main thread).
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list