tkinter, threads and asyncore together

Peter Hansen peter at engcorp.com
Wed Feb 11 14:21:22 EST 2004


george.trojan at noaa.gov wrote:
> 
> My application consists of Tkinter GUI that has to communicate with a
> remote
> server. The communication is bi-directional: the GUI responds to remote
> requests and user actions uch as pressing a button) should send messages
> 
> to the server. I want to have the network interface implemented as a
> separate
> thread, as it may take a while to proccess incoming messages. My initial
> approach is the following
> 
>  ------   Queue   --------------------
> |      | <------ |      asyncore      |        socket
> | GUI  |    ?    |dispatcher_with_send| <------------------>  server
> |      | ------> |                    |
>  ------           --------------------
> 
> My question is how to communicate with asyncore (to send a message, or
> end the thread)? I started with creating an additional dispatcher class
> using unix domain socket, but is seems wrong, why use sockets within the
> same process? I might try file_dispatcher around a pipe, but maybe I
> should use different design altogether.

I don't know what, if anything, asyncore has for that, but it's 
"competition" Twisted has something called callFromThread().  This 
method arranges for the specified callable to be called from within
the asynchronous loop at the next opportunity, allowing a separate
thread to communicate back to the objects in the async thread.

Maybe asyncore has something similar?  (Checking the docs for it, 
I can't see anything that would help.)

-Peter



More information about the Python-list mailing list