RE: [ZODB-Dev] ZEO ClientStorage's use of the asyncore main loop(was [Fwd: Re: [Zope3-dev] Twisted Publisher and Zope 2])

2005-12-09 Thread Tim Peters
[Jim]
> Historical note: asyncore didn't support private event loops either until
> I added the extra argument to the constructor.  I'm not sure why you need
> to pass the map to anything but the constructor.  Oddly. most, but not
> all of the methods that take a map, default to the one set in the
> constructor.  I don't really remember the details

AFAICT, in 2.4.2 all asyncore _methods_ default to the map passed to the
constructor.  This isn't always dead obvious, but it's never truly subtle;
e.g., this is as bad as it gets:

def set_socket(self, sock, map=None):
self.socket = sock
self._fileno = sock.fileno()
self.add_channel(map)

The only trick there is that if you don't pass map= to set_socket(), it
passes None on to add_channel(), and add_channel() then uses self._map.

The asyncore _functions_ are a different story, but I suppose they have to
be.  You do have to pass a map to poll(), poll2(), loop() and close_all(),
else they'll use the module global socket_map.  But they aren't methods, so
have no way to know any better.

Also, AFAICT, this is all equally true in 2.3.5's asyncore.  It's OK to stop
being afraid of bad code in Python 1.5.2 ;-)

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


RE: [ZODB-Dev] ZEO ClientStorage's use of the asyncore main loop (was[Fwd: Re: [Zope3-dev] Twisted Publisher and Zope 2])

2005-12-09 Thread Tim Peters
[Jim Fulton]
...
>
> 2. The ZEO client storage doesn't work optimally if there isn't a
>   main loop.  In particular, without an asyncore main loop, a
>   ZEO client storage won't see messages from the ZEO server until
>   the client storage tries to read or write some data from or to
>   the ZEO storage server.

Just FYI, in "current" ZODB this is probably less of an issue than it used
to be, since Connection now implements ISynchronizer and sets up Connection.
_storage_sync() as its ISynchronzizer afterCompletion() and newTransaction()
methods.  Maybe that's one reason you didn't see as much damage in current
Zope3 as it may have been possible to imagine ;-)

___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] ZEO ClientStorage's use of the asyncore main loop (was [Fwd: Re: [Zope3-dev] Twisted Publisher and Zope 2])

2005-12-09 Thread Jim Fulton

Shane Hathaway wrote:

Jim Fulton wrote:


Tim and I have discussed this for some time.  We think an
asynchronous I/O approach is still appropriate, to handle
asynchronous messages from servers to clients, but we need
to get away from expecting a server to provide the asyncore
main loop needed by ZEO. Rather, ZEO should provide its own
main loop running in a separate thread. (Or, possibly, each
client storage should have its own thread.) Among other things,
this would allow us to get rid of the horribly complex dual-mode
code we have now.



I think that's a good strategy.


(Note that we've had lots of frustration with asyncore.  It is
   tempting to get rid of that at the same time.  However, we still
   need an asynchronous I/O framework.  This would probably requite
   a switch to Twisted.  This might be worthwhile, but would almost
   certainly entail a lot of risk.  I'm not at all sure the benefit
   is worth it unless there were some able volunteers who wanted to
   work on it.)



Last I checked, Twisted could not support a private event loop.  Twisted 
assumes there is only one event loop for all threads.  I'd like to know 
if this has changed.  The asyncore module can support a private event 
loop, although it's ugly--you have to pass the 'map' argument all over 
the place.


Historical note: asyncore didn't support private event loops either
until I added the extra argument to the constructor.  I'm not sure why
you need to pass the map to anything but the constructor.  Oddly. most,
but not all of the methods that take a map, default to the one set in the
constructor.  I don't really remember the details

Jim

--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] ZEO ClientStorage's use of the asyncore main loop (was [Fwd: Re: [Zope3-dev] Twisted Publisher and Zope 2])

2005-12-09 Thread Shane Hathaway

Jim Fulton wrote:

Tim and I have discussed this for some time.  We think an
asynchronous I/O approach is still appropriate, to handle
asynchronous messages from servers to clients, but we need
to get away from expecting a server to provide the asyncore
main loop needed by ZEO. Rather, ZEO should provide its own
main loop running in a separate thread. (Or, possibly, each
client storage should have its own thread.) Among other things,
this would allow us to get rid of the horribly complex dual-mode
code we have now.


I think that's a good strategy.


(Note that we've had lots of frustration with asyncore.  It is
   tempting to get rid of that at the same time.  However, we still
   need an asynchronous I/O framework.  This would probably requite
   a switch to Twisted.  This might be worthwhile, but would almost
   certainly entail a lot of risk.  I'm not at all sure the benefit
   is worth it unless there were some able volunteers who wanted to
   work on it.)


Last I checked, Twisted could not support a private event loop.  Twisted 
assumes there is only one event loop for all threads.  I'd like to know 
if this has changed.  The asyncore module can support a private event 
loop, although it's ugly--you have to pass the 'map' argument all over 
the place.


Shane
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev


Re: [ZODB-Dev] ZEO ClientStorage's use of the asyncore main loop (was [Fwd: Re: [Zope3-dev] Twisted Publisher and Zope 2])

2005-12-08 Thread Jim Fulton

Jim Fulton wrote:


Here is a draft of a note I plan to send to the zodb list soon:


Sigh, I meant to take this line out. :)

Jim


--
Jim Fulton   mailto:[EMAIL PROTECTED]   Python Powered!
CTO  (540) 361-1714http://www.python.org
Zope Corporation http://www.zope.com   http://www.zope.org
___
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev