tkinter, threads and asyncore together

Jp Calderone exarkun at
Wed Feb 11 20:24:51 CET 2004

On Wed, Feb 11, 2004 at 07:11:58PM +0000, george.trojan at 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.

  You need something selectable to wake asyncore up from its call to
select().  The easiest way to do this is with a pipe.  You don't have to
send any actual message over the pipe, though; one byte will be enough to
get asyncore to call back into your code, then you can retrieve the message
from wherever it is (eg, in a Queue.Queue).


More information about the Python-list mailing list