Mixing asyncore with threads
Thomas Jensen
thomasNO at SPAM.obscure.dk
Mon Oct 22 18:39:50 EDT 2001
More information about the Python-list mailing list
Mon Oct 22 18:39:50 EDT 2001
- Previous message (by thread): Mixing asyncore with threads
- Next message (by thread): Mixing asyncore with threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, Is it possible/advisible to mix asyncore (or modules using it) with threads ? 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 calculating. 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 ? -- Best Regards Thomas Jensen
- Previous message (by thread): Mixing asyncore with threads
- Next message (by thread): Mixing asyncore with threads
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list