[Zope3-dev] Re: [Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/SmtpService/Views - __init__.py:1.1 configure.zcml:1.1

Guido van Rossum guido@python.org
Wed, 30 Oct 2002 13:22:41 -0500


> asyncore.py is still in use, since we did not have the time to
> replace it.  Shane liked the Twisted approach to asyncore, so we
> wanted to glean at it for some ideas, but as said, this is still
> open.

IMO (after having worked with it extensively in ZEO/zrpc) asyncore is
a really small piece of functionality that you'll need no matter how
you slice it, if you don't want to do all your I/O synchronously
(which would mean one thread per connection).

The one problem with asyncore is that it doesn't work well in a
threaded environment: if thread A is executing the asyncore main loop
and blocked in a select() or poll() call for file descriptors x and y,
and thread B adds file descriptor z to the set of filedescriptors of
interest, thread A won't wake up until x or y is ready, or until it
times out.  The solution for this is pretty icky (in part because
asyncore doesn't provide one itself, so the solution has to hack into
asyncore's internals).  I don't know what Twisted does -- is it any
better?

There's also a minor (?) problem that asyncore makes it possible for
multiple threads to simultaneously invoke the asyncore loop -- this is
a bad idea, however, unless you use different sets of file descriptors
in each thread.

--Guido van Rossum (home page: http://www.python.org/~guido/)