killing thread after timeout
Paul Rubin
http
Thu Sep 8 07:40:16 EDT 2005
Bryan Olson <fakeaddress at nowhere.org> writes:
> First, a portable worker-process timeout: In the child process,
> create a worker daemon thread, and let the main thread wait
> until either the worker signals that it is done, or the timeout
> duration expires. As the Python Library Reference states in
> section 7.5.6:
Maybe the child process can just use sigalarm instead of a separate
thread, to implement the timeout.
> If Unix-only is acceptable, we can set up the accepting socket,
> and then fork(). The child processes can accept() incomming
> connections on its copy of the socket. Be aware that select() on
> the process-shared socket is tricky, in that that the socket can
> select as readable, but the accept() can block because some
> other processes took the connection.
To get even more OS-specific, AF_UNIX sockets (at least on Linux) have
a feature called ancillary messages that allow passing file
descriptors between processes. It's currently not supported by the
Python socket lib, but one of these days... . But I don't think
Windows has anything like it. No idea about QNX.
More information about the Python-list
mailing list