asyncore, asynchat and threads

Peter Hansen peter at engcorp.com
Wed Aug 4 08:10:47 EDT 2004


Joshua Moore-Oliva wrote:

> I have to not return any data until there is data to 
 > return for that specific connection.  If there is some
 > way to send data down a asynchat
> socket from another thread (thread-safely), or to 
 > somehow wake up an asynchat class, that would be great.

It's been years since I used asyncore (I find Twisted much
simpler to use) but at least in theory such a thing is
possible.  Twisted has a callFromThread() method that can
be used to get a callback in another thread to be called
from the "reactor" (the equivalent of the asyncore core
loop), which would do what you want.  Asyncore might have
similar facilities.

I don't _fully_ grasp what you are doing, and I don't work
well without pictures in such cases (got a whiteboard handy?
draw a picture and send me a digital photo :-), but so
far it doesn't sound like you have anything approaching
unusual, compared to many other applications I've seen doing
the sorts of things yours seems to be doing.

-Peter



More information about the Python-list mailing list