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

Dieter Maurer dieter@handshake.de
Mon, 29 Jan 2001 19:26:56 +0100 (CET)


Donovan Baarda writes:
 > 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.
Thank you for this good explanation.

By now, I think, it would not be usefull for ZServer, at least
not for standard operations.

   ZServer is a multi-threaded server, where different requests
   are serviced by different threads.
   The thread may block and does simply not return from "more()".

   On first thought, you patch might free some blocked threads
   to do productive work. However, Zope's transaction system
   is linked to thread management. If you patch would be used
   for that, Zope's transaction subsystem would need to be
   rewritten.


Dieter