Mixing asyncore with threads
thomasNO at SPAM.obscure.dk
Tue Oct 23 00:39:50 CEST 2001
Is it possible/advisible to mix asyncore (or modules using it) with
More specifically, I'd like to build a HTTP based server, which will
serve, more or less, IO bound content most of the time (served directly
from memory/disk/DB). For this asyncore seems ideal.
However, in some circumstances the content will be quite CPU intensive
(like dynamically generated PNGs from a large dataset, etc.). In this
case a thread would be nice, to prevent blocking other trafic while
The problem is, that select() will block until it sees trafic on a
readable or writeable port (AFAIK).
So far I've come up with the following solutions:
(1) Wraping asyncore.poll() in a loop with a small timeout value.
(2) Use a "dummy" port on the loopback interface for triggering
select() once output from the thread is finished.
Of the two, I like (2) best, but I keep getting the feeling that there
must be a better way ?
Perhaps I should just settle on either asyncore or threads ?
More information about the Python-list