Modification to asyncore.py to support threaded event loop
jcarlson at uci.edu
Fri Nov 5 09:40:02 CET 2004
abpillai at gmail.com (Anand Pillai) wrote:
> I tried your code and this is the result...
> asyncore does not have an attribute named 'map', only socket_map.
> 'map' is an argument to ascynore.loop function, again not its
socket_map then, whatever.
> Did you try this code out before posting it here?
No, I typed it out in my email client. But my statement still holds,
the functionality is trivial to implement if you know what you are doing,
and shouldn't be in the asyncore module.
> Also, asyncore.loop has a while loop inside it, and you are adding
> another while loop on top. Clearly your exit condition, if it works is
> going to only exit the outer while loop, not the inner one. I dont
> think it is going to work.
If you check the source code for asyncore.py in Python 2.4 (available
from Python CVS), you will discover that you can provide an optional
'count' argument to asyncore.loop. You'll notice that I both mention
> > With the asyncore that will be included with Python 2.4, loop() has a
> > 'count' argument. Your 'programmable exit condition' is simple...
and use it:
> > asyncore.loop(timeout=30.0, use_poll=False, map=map, count=1)
In this case, the 'inner loop' only runs for one pass. Certainly in
Python <2.4, it would run without stopping (unless the socket map became
empty), but I was referencing 2.4, not 2.3 or prior.
More information about the Python-list