asyncore.loop As A Win32 Service

Giles Brown giles_brown at
Thu Mar 27 09:25:11 CET 2003

John Abel <johnfabel at> wrote in message news:<mailman.1048529848.24545.python-list at>...
> I'm writing a service, and have come across a problem with 
> asyncore.loop.  There doesn't seem to be a way for it to interrupted, 
> when the service is issued a stop.  To get round this with a similar 
> program using SocketServer, before executing handle_request I checked 
> for connections with  The way I'm thinking of doing it, 
> is to override asyncore.loop, set an event, launch the new asyncore.loop 
> in a thread, and replace the while 1 in asyncore.loop with a check for 
> the event.  Does that sound about the right to go about it?

If you have a look at the medusa/thread/ file (get the
CVS one if possible as the release isn't very up to date) at:

You will see another way of doing it.  This uses a trick where the
code internally sets up a pair of connected sockets.  You can then 
wake up (trigger) the thread with the asyncore.loop in it by writing
to the one of the connected sockets.

Giles Brown

More information about the Python-list mailing list