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_wit h_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 3841 ge***********@n oaa.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_wit h_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
"competitio n" 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***********@n oaa.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_wit h_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***********@n oaa.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_wit h_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***********@n oaa.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_wit h_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; like telnet is a client. The user
should be able to bind() to a port and wait for a client. The written
and recieved data is stored in a Text widget, self.__text. The
accept()ing is done in a seperate thread (using the threading module),
in...
|
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 blocks.
The asyncore.poll(timeout=0.01) functions however works fine. Thus I have:
while 1:
|
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 things up. After the file dialog, I can no longer use
the Text widget (typing, selecting, it doesn't work anymore!)
What am I doing wrong?
TIA,
--Irmen de Jong
|
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). (This is all for a
multi-player game server, so the threads would be individual games,
that need to update the players when new events happen in the game)
I currently have a module level list of async_chat instances, which the
thread then reads...
|
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 list within a single object,
which is then placed on a stack(This cuts down thread creation and deletions
roughly by a factor of 4). I create up to 12 threads, which then process a
single object off of the stack. I use a loop with a boolean...
| |
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 time on their computer. A
message box confirms that the time was recorded All seems well.
In the main thread when attempting to record this variable's activity it
seems stuck on the inital value this variable contained, though it indicates
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 displays it in a
Tkinter text widget. Some of the commands are long-running and/or return
thousands of lines of output.
I initially thought I needed to use threading, because the GUI would
block when reading the output, even when I configured...
|
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
server" and "Stop server".
The first button should start the asyncore main loop while the second
should obviously stop it.
Actually I can't find a valid solution for doing such a stuff since
this is the first time I'm using a GUI toolkit....
|
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 techniques, and then do stuff with
the results in parallel. Think of something like Google's map-reduce.
It sounds like this would be something someone else has done before. I
searched google, but I don't think there is any discussion anywhere...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |