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.
George 5 3813 ge***********@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
On Wed, Feb 11, 2004 at 07:11:58PM +0000, ge***********@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.
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).
Jp ge***********@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.
George
#to control asyncore
while 1:
asyncore.loop(.1)
if not fromgui.empty():
#handle messages from GUI
Another option is to just have one thread, with the mainloop of Tkinter
do a single asyncore.loop(0) call every .01 seconds or so. In wxPython
I'd just use a wxTimer, I don't know if Tkinter has an equivalent.
- Josiah
> #to control asyncore while 1: asyncore.loop(.1) if not fromgui.empty(): #handle messages from GUI
Another option is to just have one thread, with the mainloop of Tkinter do a single asyncore.loop(0) call every .01 seconds or so. In wxPython I'd just use a wxTimer, I don't know if Tkinter has an equivalent.
I meant asyncore.poll(.1) and asyncore.poll(0) respectively.
- Josiah
Josiah Carlson wrote: ge***********@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.
George
#to control asyncore while 1: asyncore.loop(.1) if not fromgui.empty(): #handle messages from GUI
Another option is to just have one thread, with the mainloop of Tkinter do a single asyncore.loop(0) call every .01 seconds or so. In wxPython I'd just use a wxTimer, I don't know if Tkinter has an equivalent.
Yep: use the after method to call a function from the Tkinter main loop after a
given delay. See http://www.pythonware.com/library/tk...-and-other.htm
HTH
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Michael Schutte |
last post by:
I know, questions about Tkinter and threads have been answered very
often, but I want to ask anyway.
I am using Python 2.2 on a Linux (SuSE Linux 8.1) system.
I want to write a server application;...
|
by: duane voth |
last post by:
> #to control asyncore
> while 1:
> asyncore.loop(.1)
> if not fromgui.empty():
> #handle messages from GUI
The above doesn't work for me - asyncore.loop(<anything>) always...
|
by: Irmen de Jong |
last post by:
Hi,
I'm having trouble with the code below.
It's just a regular Tk text widget in which you can type and
select text as expected, however the call to tkFileDialog.askopenfilename()
seems to screw...
|
by: Jos |
last post by:
Hello.
I'm using the asyncore and _chat modules to create a network server. I
also have, running in a separate thread(s), a "producer" which needs to
"push" data onto the network connection(s)....
|
by: m |
last post by:
Hello,
I have an application that processes thousands of files each day. The
filenames and various related file information is retrieved, related
filenames are associate and placed in a linked...
|
by: scorpion53061 |
last post by:
In a seperate thread I assign a variable called timeofentry based on the
output of the GetDate function on my SQL Server. The idea is to be able to
base the time of the users actions outside of the...
|
by: Nathan Pinno |
last post by:
Hi,
Can anyone tell me if pygame and Tkinter can work together in the same
application? I thought I'd better ask before trying it, since both use
widgets.
Thanks,
Nathan Pinno
--
|
by: Kevin Walzer |
last post by:
I'm trying to decide whether I need threads in my Tkinter application or
not. My app is a front end to a command-line tool; it feeds commands to
the command-line program, then reads its output and...
|
by: Giampaolo Rodola' |
last post by:
Hi there.
Just for the heck of it I'd like to write a simple front-end for an
asyncore-based server I wrote by using Tkinter.
I wrote a simple graphical interface consisting of two buttons: "Start...
|
by: Jonathan Gardner |
last post by:
So, I ran into a problem that I would like to write as little code as
possible to solve.
The problem is that I would like to send out a bunch of HTTP requests
simultaneously, using asynchronous...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |