Newbee question here.

brueckd at tbye.com brueckd at tbye.com
Sat Aug 11 22:33:14 EDT 2001


On 12 Aug 2001, Patio87 wrote:

> What exactly does medusa do?

Medusa makes writing asynchronous I/O apps (using the C select/poll
functions) much easier - its two main modules come as part of the standard
Python distribution, and I'd recommend reading the asyncore.py and
asynchat.py source code for more information.

The basic idea is that you can write, for example, a web server using
multiple threads or using a single thread and asynchronous I/O. Since most
servers are I/O bound, it makes sense to let the I/O drive the program
(with a multithreaded server the thread scheduler would continously switch
between threads even if the switched-to thread didn't have any work to do
at the moment).

You can make a fairly high-performance server in Python using Medusa;
asyncore has a dispatcher class that you subclass for general use, and
asynchat creates a asyncore.dispatcher-based class that you subclass for
use with protocols like HTTP. If you've never programmed asynch I/O before
then the first time you use it it'll seem kinda confusing. Once you get
the hang of it, though, it performs pretty well and is really pretty neat.

-Dave





More information about the Python-list mailing list