Problem with signals & exceptions...

Gordon McMillan gmcm at hypernet.com
Tue Jul 27 19:48:01 EDT 1999


Eric Lee Green writes:

> I'm having trouble catching my thrown exceptions under FreeBSD 3.2.
> I am using the Python 1.5.2 that came with FreeBSD 3.2 (well, on
> disk 1 of the <n>-disk set). The following program works properly
> under Red Hat Linux version 6.0 running a self-compiled Python 1.5.2
> (in place of the 1.5.1 which comes with Red Hat 6.0, which does not
> properly handle signals during socket i/o calls). How it works: it
> listens to port 6664. When it gets a connection, it then sets an
> alarm handler and alarm and then tries to read from the socket. If
> it does not get data within 10 seconds, it then times out, at which
> point the alarm handler throws an exception and aborts the socket
> read.  

Why not avoid the pain of signals (which have enough gotchas to 
destroy portability) and use a select with a 10 sec timeout. If 
there's nothing in the readable list when it returns, bail out.

- Gordon




More information about the Python-list mailing list