[Python-ideas] asyncore: included batteries don't fit
Guido van Rossum
guido at python.org
Mon Oct 8 22:00:45 CEST 2012
On Mon, Oct 8, 2012 at 12:20 PM, Mark Adam <dreamingforward at gmail.com> wrote:
> On Sun, Oct 7, 2012 at 9:01 PM, Guido van Rossum <guido at python.org> wrote:
>> On Sun, Oct 7, 2012 at 6:41 PM, Ben Darnell <ben at bendarnell.com> wrote:
>>> I think there are
>>> actually two separate issues here and it's important to keep them
>>> distinct: at a low level, there is a need for a standardized event
>>> loop, while at a higher level there is a question of what asynchronous
>>> code should look like.
>> Yes, yes. I tried to bring up this distinction. I'm glad I didn't
>> completely fail.
> Perhaps this is obvious to others, but (like hinted at above) there
> seem to be two primary issues with event handlers:
> 1) event handlers for the machine-program interface (ex. network I/O)
> 2) event handlers for the program-user interface (ex. mouse I/O)
> While similar, my gut tell me they have to be handled in completely
> different way in order to preserve order (i.e. sanity).
> This issue, for me, has come up with wanting to make a p2p network
> application with VPython.
Interesting. I agree that these are different in nature, but I think
it would still be useful to have a single event loop ("reactor") that
can multiplex them together. I think where the paths diverge is when
it comes to the signature of the callback; for GUI events there is
certain standard structure that must be passed to the callback and
which isn't readily available when you *specify* the callback. OTOH
for your typical socket event the callback can just call the
appropriate method on the socket once it knows the socket is ready.
But still, in many cases I would like to see these all serialized in
the same thread and multiplexed according to some kind of assigned or
implied priorities, and IIRC, GUI events often are "collapsed" (e.g.
multple redraw events for the same window, or multiple mouse motion
I also imagine the typical GUI event loop has hooks for integrating
file descriptor polling, or perhaps it gives you a file descriptor to
add to your select/poll/etc. map.
Also, doesn't the Windows IOCP unify the two?
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas