I'm coming from Tcl-world ...

Oren Tirosh oren-py-l at hishome.net
Sat Aug 3 19:23:33 CEST 2002

On Sat, Aug 03, 2002 at 05:48:19PM +0100, Robin Becker wrote:
> >Write an object with the following methods:
> >
> >   writable() - return true if you wish to get write events
> >   readable() - return true if you wish to get read events
> >
> >   handle_error() - called on any errors
> >   handle_write_event() - called on write event
> >   handle_read_event() - called on read event 
> >       also called on EOF, in that case reading will return ''
> >
> >set socket_map[fd] to point to this object (multiple objects, more likely)
> >call asyncore.loop(optional_timeout)
> >The loop will return either on timeout or when one of the handlers
> >raises the asyncore.ExitNow exception.
> >
> >That's all.
> ......
> Inspired by Steve Holden in another thread I was just looking at
>     http://www.python.org/dev/doc/devel/lib/module-asyncore.html
> and see no mention of the handle_write_event & handle_read_event
> methods. I assume they're aliases for handle_write and handle_read.

No.  The methods handle_read_event and handle_write_event are the low
level methods that get called directly by the asyncore loop. That's
what I use when I implement my own dispatcher from scratch. The dispatcher
class in the asyncore module implements them for you and calls the 
handle_read and handle_write methods that you're supposed to override.


More information about the Python-list mailing list