473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Get data from a Queue to a wxtextcontrol

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) ?
Jun 7 '07 #1
5 1824
bartonc
6,596 Expert 4TB
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.
Jun 7 '07 #2
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.
Jun 7 '07 #3
bartonc
6,596 Expert 4TB
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).
Jun 7 '07 #4
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
Jun 8 '07 #5
bartonc
6,596 Expert 4TB
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.
Jun 8 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
6
by: herrcho | last post by:
#include <stdio.h> #define MAX 10 int queue; int front, rear; void init_queue() { front=rear=0; }
10
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...
30
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...
1
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...
2
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...
4
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...
5
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...
9
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.