I'm not subscribed to the zope-dev list (got enough email thanks :-), but I
thought some of you might be interested in the following patch to medusa
that I sent to the medusa list (ZServer is based on medusa).
I remember reading ages ago on a wishlist for ZServer that someone was
thinking of adding blocking support to producers. This patch adds support
for just that in a non-intrusive way. I haven't tried applying this patch to
ZServer, but it _should_ work.
The two things to look out for when applying these changes to older
programs that use asynchat.py and producers.py are; old producers with
existing and conflicting ready() methods, anything that uses the
compound_producer because the __init__ method has been simplified.
I hope someone finds this useful, and would appreciate any feedback.
----- Forwarded message from Donovan Baarda <[EMAIL PROTECTED]> -----
I've recieved one note of interest in my patch for medusa to allow producers
to block using a ready() method. The gist was "this is a good idea, but it
doesn't work". At the time I was focusing on the ftp server part of medusa,
so I hadn't checked the http side much at all.
I also noticed that asyncore.py and asynchat.py were distributed without
producers.py in python itself. My original changes made asynchat.py
dependant on producers.py, which was probably a bad idea.
So I have gone right over my changes and produced a new, more thoroughly
tested patch that tries to minimize the side affects. I have tested the
changes as they are incrementaly applied to ensure that my changes don't
break old code that doesn't use the ready() feature. This patch contains
all changes made to all files, but you only need to accept the changes to
some files to use ready()
The main change is to asynchat.py, where support for the ready() method has
been added. Also added are a variety of producer base classes that allow new
producers with ready() support to be easily derived (and removed the
asynchat.py dependancy on producers.py that my early patch introduced). The
main async_chat class is actualy significantly simpler for the change,
mostly due to replacing the fifo class with a fifo_producer class. The
find_prefix_at_end procedure for finding terminators has also been
simplified and speeded up. Overall, asynchat.py is only 23 lines bigger
dispite all the additional functionality.
The good news is, the changes to asynchat.py are fully backwards compatible
and medusa runs fine with all other files unchanged, _except_ that
filesys.py and status_handler.py have conflicting ready() methods in
producers. These ready() methods are unused in the original medusa, but
cause the new asynchat.py to think the producers never complete. The patch
to these two files simply removes these ready() methods so medusa can run
with the new asynchat.
The next lot of serious changes are to producers.py and http_server.py.
These changes are not needed to run medusa as it stands, but are needed if
you start using blocking producers. The changes primarily make the producers
inherited from the base producer classes defined in asynchat.py. This
ensures that producers that wrap other producers will block correctly. The
inheritance of features makes producers.py 62 lines smaller than it was. All
the changes to producers.py are backwards compatible _except_ the
compound_producer.__init__() method now takes a python list of producers not
a fifo. The changes to http_server.py take this into account.
The final trivial change is a commented out alternative to use the new
async_producer instead of file_producer in ftp_server.py. This allows medusa
filesystems to return file types that could block without blocking the whole
I hope someone gets a chance to try these out, and I would appreciate any
form of feedback. I'm tempted to submit my patch to asynchat.py direct to
the Python people for inclusion in Python 2.1, but would like to hear more
feedback before I do.
BTW, ignore the patch to "medusa.prj"... that is a side affect of using
prcs to revision control my changes. This patch is to the 20000601 version
ABO: finger [EMAIL PROTECTED] for more info, including pgp key
Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists -