Re: [Zope-dev] asynchat producer ready() method patch.

2001-01-28 Thread Donovan Baarda

On Sun, Jan 28, 2001 at 09:31:07PM +0100, Dieter Maurer wrote:
 Donovan Baarda writes:
   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.
 What does "blocking support dor producers" mean?

Disclaimer: you must be moderately familiar with ZServer/medusa/asynchat for
the following to make sense;

Asynchat used by ZServer and medusa use producers as a way to "push" data
through an async interface. The current version of asynchat requires that
producers be able to produce data immediately on calling their more()
method, untill they are finished, when they return ''. 

My patch adds support for producers being able to "block" by letting
asynchat know if they are ready via a ready() method. This allows you to use
the simple producer model to push data that may not be immediately
available. An example would be a http-fetch producer that fetches data from
upstream for a proxy.

This patch is only useful for people creating or modifying things like
medusa or ZServer.

-- 
--
ABO: finger [EMAIL PROTECTED] for more info, including pgp key
--

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] asynchat producer ready() method patch.

2001-01-27 Thread Donovan Baarda

G'day zope-dev,

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.

Thanks,

ABO

- Forwarded message from Donovan Baarda [EMAIL PROTECTED] -
G'day,

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
server.

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 2601 version
of medusa.

-- 
--
ABO: finger [EMAIL PROTECTED] for more info, including pgp key
--

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] Re: asynchat producer ready() method patch.

2001-01-27 Thread Donovan Baarda

On Sat, Jan 27, 2001 at 09:30:16PM +1100, abo wrote:
 G'day zope-dev,
 
 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).
[...]

whups... didn't attach the patch. Rather than bombard everyone with a 10k
patch, it can be found at;

ftp://minkirri.apana.org.au/pub/python/medusa-ready_0.3.patch.bz2

-- 
--
ABO: finger [EMAIL PROTECTED] for more info, including pgp key
--

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )