[wxPython-users] wxTimer never times out sometimes

Josiah Carlson jcarlson at uci.edu
Thu Aug 17 08:45:07 PDT 2006


Jeffrey Barish <jeff_barish at earthlink.net> wrote:
> 
> I use the timer in one-shot mode to trigger an action after the user stops
> using the GUI.  As long as the user is clicking on elements in the GUI, the
> timer gets retriggered (using Start).  This scheme works fine most of the
> time, but once in a while the event handler never gets called.  After the
> timer fails once, it seems to be inoperable.  That is, I don't get a
> timeout after performing additional actions that normally would trigger the
> timer.  The only way to restore correct operation is to exit the program
> and restart it.  My only theory is that something goes wrong if wxTimer
> receives a start command at the same time that it is timing out.  That is
> the only scenario I can think of consistent with the sporadic nature of the
> problem.  Perhaps there needs to be a critical section in the code.

If you are using wxTimer.Start() in a thread other than the main thread,
then you need to change your code, as such is not supported on any
platform (regardless of whether it works or not on your platform).  That
is, post an event to the GUI thread, that event's only job is triggering
the wxTimer.Start().

If the only thread that is executing is your single main thread, then I
doubt you are running into a race condition that requires a critical
section or lock (either in the underlying wxPython implementation or in
your code), but you may need to wait for a response from Robin to be
sure.


 - Josiah





More information about the wxpython-users mailing list