asyncore, asynchat and threads

Joshua Moore-Oliva josh at
Wed Aug 4 03:46:06 CEST 2004

Ok..  so here is my situation.  

I have an application that I would love to be able to use asynchat with for it's handle_close, found_terminator etc abstraction on.

However, I must use a separate thread for each connection as the work resulting from the communication can result in blocking for an indefinate period of time.

What I would love to do for each thread that is created, is to spin off an asynchat subclass and manually run some kind of loop() function that will do the 
polling//select etc for me, in a threadsafe manner, only on the one asynchat class/connection for that thread (e.g. I supply variables to keep track of the data)

I have come across some sparse documentation that mentioned asyncore.loop() can be supplied a map of some sorts to loop through..  However, I have no idea
how to create this map to pass to asyncore.loop, nor what thread-safe precautions (if any) I need to make.

A simple example of a thread-safe way to create an asynchat subclass and get it to run would be great...

even any pointers, help, ideas on how to make something like this work would be greatly appreciated as well.

Thanks, Joshua Moore-Oliva

More information about the Python-list mailing list