Hello, from linux I have created an interactive telnet session with a chess server.
With a combination of the threading, pexpect and Queue modules I put all recieved data into a queue.
The only way I can think of getting the data from the queue to a
wxtextcontrol is to have a wx.timer (set to a short interval) keep inspecting the queue.
This method seems to work OK, but I am wondering if there is a 'better' method than using a timer.
If wx.timer is the only method, if I use an interval of 1 will the timer just run as fast as possible or should I try to find an exact value (eg 100) ?
5 1814
Hello, from linux I have created an interactive telnet session with a chess server.
With a combination of the threading, pexpect and Queue modules I put all recieved data into a queue.
The only way I can think of getting the data from the queue to a
wxtextcontrol is to have a wx.timer (set to a short interval) keep inspecting the queue.
This method seems to work OK, but I am wondering if there is a 'better' method than using a timer.
If wx.timer is the only method, if I use an interval of 1 will the timer just run as fast as possible or should I try to find an exact value (eg 100) ?
I like the idea of using a wxTimer to keep the display current with data that may be changing in the background. In fact, I use this technique often. I don't think that it's a good idea to run "as fast as possible", though. You only want to run fast enough (probably twice as fast as it takes for new data to arrive) to keep up with the changes in the data. I'd say that if you're entering the OnTimerN() handler and finding an empty queue more than 4 times for every time you find new data in the queue, you'll save processing overhead by cutting the value down (perhaps in half).
Just my opinion, though.
I like the idea of using a wxTimer to keep the display current with data that may be changing in the background. In fact, I use this technique often. I don't think that it's a good idea to run "as fast as possible", though. You only want to run fast enough (probably twice as fast as it takes for new data to arrive) to keep up with the changes in the data. I'd say that if you're entering the OnTimerN() handler and finding an empty queue more than 4 times for every time you find new data in the queue, you'll save processing overhead by cutting the value down (perhaps in half).
Just my opinion, though.
That's interesting, I hate the idea of wasting resources, BUT the data from the server is 'arratic' at best. Sometimes 20secs between lines then 50 lines arrive together.
Thanks for the tips, I'll have to experiment a bit more.
That's interesting, I hate the idea of wasting resources, BUT the data from the server is 'arratic' at best. Sometimes 20secs between lines then 50 lines arrive together.
Thanks for the tips, I'll have to experiment a bit more.
That make sense. I'm used to processes that require more regular servicing (like sampling analog data).
That make sense. I'm used to processes that require more regular servicing (like sampling analog data).
Brilliant! I followed your previous advise on counting the number of times timer tries to read an empty queue. After a bit of tweaking my code works so much better.
Thanks
Brilliant! I followed your previous advise on counting the number of times timer tries to read an empty queue. After a bit of tweaking my code works so much better.
Thanks
It makes me very happy that we can share and exchange our Python experience and knowledge this way. This forum is beginning to shape into the Python help forum of my dreams.
Thank you so much for your participation.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brian Alexander |
last post by:
Hello;
I am trying to protect some global data, which may, in the future, be
accessed by threads. I'm not sure how to implement a locking mechanism
in python. Here is the idea I'm trying to...
|
by: herrcho |
last post by:
#include <stdio.h>
#define MAX 10
int queue;
int front, rear;
void init_queue()
{
front=rear=0;
}
|
by: # include |
last post by:
queue is importnant in people live to organize the cocity, this code i
wnat to share with others
and recieve comment about, with all of my thanks
# include<stdio.h>
# define MAX 100
typedef...
|
by: Charles Law |
last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this
once before, but ...".
Two users are both looking at the same data, from a database. One user
changes the data and...
|
by: maiami2 |
last post by:
Hi Guys,
I'm very new to access and I've been trying to get the hang of it over the last few days, but I've become very confused with various aspects of how to code it.
Introduction:
I am...
|
by: jonosborne |
last post by:
Hi,
I have created two basic queries which both output a two column table, one (query A) has the columns 'Queue' and 'Errors' and the other (query B) has the columns 'Queue' and 'Correct'.
I...
|
by: Boki |
last post by:
Hi All,
I need to let user type some text in a textbox, and user will click a
button to submit the material.
It is very straightforward if we implement it by single thread.
But the...
|
by: akenato |
last post by:
Hi for me this is th first time that I use c++. I have to do this exercise. Somebody can help me?
Thanx.
Implement a FIFO-queue ( first in, first out ) as a ring buffer. Use a static array as the...
|
by: =?Utf-8?B?U2hhdW5P?= |
last post by:
I have a TCPIP socket providing data to my app.
My app works on messages (not textual) with a predefined footer (eg 0x01
followed by 0x02)
How should i go about buffering this and retrieving the...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |