473,231 Members | 1,792 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,231 software developers and data experts.

Starting a thread before wxPython bootup ... interesting.

Hello folks,

I'm having an issue with mixing wxPython and threading ... I realize
multi-threading always introduces subtle bugs, but the following
scenario is just odd:

I start a dummy thread, that does nothing but increment a counter and
print its value to the screen, then afterwards, I start the wxPython
application. I get nothing but weird behavior: sometimes the gui just
crashes, sometimes I get an exception, sometimes it runs for a little
but very slowly ...

Anyone know whats going on? I have a dual-core T5500, so multi
threading is piece of cake for it hardware -wise.
Cheers,
--Shafik

Oct 4 '07 #1
3 1593
On 10/4/07, Shafik <sh******@gmail.comwrote:
Hello folks,

I'm having an issue with mixing wxPython and threading ... I realize
multi-threading always introduces subtle bugs, but the following
scenario is just odd:

I start a dummy thread, that does nothing but increment a counter and
print its value to the screen, then afterwards, I start the wxPython
application. I get nothing but weird behavior: sometimes the gui just
crashes, sometimes I get an exception, sometimes it runs for a little
but very slowly ...

Anyone know whats going on? I have a dual-core T5500, so multi
threading is piece of cake for it hardware -wise.
That's quite a broad and poorly specified problem to ask people to
solve with no code. You get double minus points for mentioning an
exception without saying what it was.

Below is a script that has no demonstrable problems on my machine:

import wx
import threading

if __name__ == '__main__':
run = True
def count():
counter = 0
while run:
print counter
counter += 1
thread = threading.Thread(target=count)
thread.start()
app = wx.App(False)
f = wx.Frame(None)
f.Show()
app.MainLoop()
run = False

Since the counter loop spins tightly, this causes some CPU contention
and could quite possibly cause a non-trivial GUI to respond poorly,
but that's to be expected.
Oct 4 '07 #2
Since the observed behaviour is clearly undefined,
I forgive you for the poorly specified behaviour
description: asking for a close description of random
behaviour is just ridiculous.

The most obvious point is that wx is not re-entrant
or thread safe: you have to make it so by using
wx.CallAfter()

Since you are talking about a bug in your screen
display while using a screen library, it would
also be interesting it you described the environment:
Which operating system? Which windowing system?
Which wx library? Which Python? Which IDE? What code?

[david]


Shafik wrote:
Hello folks,

I'm having an issue with mixing wxPython and threading ... I realize
multi-threading always introduces subtle bugs, but the following
scenario is just odd:

I start a dummy thread, that does nothing but increment a counter and
print its value to the screen, then afterwards, I start the wxPython
application. I get nothing but weird behavior: sometimes the gui just
crashes, sometimes I get an exception, sometimes it runs for a little
but very slowly ...

Anyone know whats going on? I have a dual-core T5500, so multi
threading is piece of cake for it hardware -wise.
Cheers,
--Shafik
Oct 5 '07 #3
>
The real goal is to start the gui in a different thread, and have the
main thread regain control. That seems like a feasible thing to be
able to do, though I have been unsuccessful ... if anyone would like
to suggest something without being covertly insulting, I'm all ears.
AFAIK some toolkits take it personally if they don't run in THE thread,
meaning the main-thread. No idea if that applies to your situation, but
as you continue to being vague, so are the answers.

Diez
Oct 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Doug Farrell | last post by:
Hi all, I just installed the wxPython-2.4.1.2 demo RPM on my RedHat Linux 9.0 machine, which has Python 2.2.2 on it, and I'm having a problem running the demo.py program. Here is a trace of the...
21
by: j_mckitrick | last post by:
Just thought I'd play devil's advocate... I tried wxPython briefly, and it had some nice features. It has a huge list of dependencies. I don't like the fonts (but I'd love to know how to get...
5
by: fooooo | last post by:
This is a network app, written in wxPython and the socket module. This is what I want to happen: GUI app starts. User clicks a button to 'start' the work of the app. When start is pressed, a new...
0
by: rob_sas | last post by:
I have two Windows Services that log the error 'The <service> service hung on starting'. (EventID 7022) int the System Log of Event Viewer. A few seconds later, they both log the message 'Service...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
6
by: cyberco | last post by:
In my wxPython app a non-GUI thread (that reads info from the network) tries to open a frame to show the new info. This results in my app hanging (which is not too surprising). Coming from a C#...
1
by: [david] | last post by:
What am I doing wrong? I'm trying to capture stdErr in a multi-threaded program. This code crashes wxPython with /Py Assertion Error: C++ assertion "m_count=-1 || m_count=-2" failed/ What I'm...
1
by: Okonita | last post by:
Hi all, I have gone through the process of installing DB2 UDBv9 Express-C in my local linux environment. I am used to having icon placed on my Desktop or taskbar for easy access to (db2cc)...
13
joedeene
by: joedeene | last post by:
ok, i have a question, can you run a console application directly from bootup on the system, like set the boot order to cd for first and have a console application on the cd and it will come up. if...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

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.