momentarily stopping events

I’m new to wxPython and a self taught novice at python.

I’m making a program that reads data from the serial port, does some number crunching, and then sends data to my wx gui, as well as another program (oziexplorer). I’m using a Python wrapper for the oziexplorer api.

The problem I’m running into is that when an event is fired in wx while the oziexplorer methods are running, oziexplorer permanently freezes, and the rest of my program freezes until it kill oziexplorer.

My program is fairly simple. The only event that has been problematic is from a wx.Timer for counting off seconds to update a clock in the gui.

Is there a simple way to temporarily stop events from being triggered?

My first solution was to stop the timer, run the oziexplorer update, and then start it again, but I can’t start it again outside of the main thread. And I’m not sure how/if I can access it from a method that is called from another thread.

I’m not looking for an elegant solution, something that works just enough will be fine. I won’t be using this code for long, so I would prefer a quite fix (that ignores the underlying problems of a n00b).

Warren Jackson wrote:

I'm making a program that reads data from the serial port, does some number crunching, and then sends data to my wx gui, as well as another program (oziexplorer). I'm using a Python wrapper for the oziexplorer api.

The problem I'm running into is that when an event is fired in wx while the oziexplorer methods are running, oziexplorer permanently freezes, and the rest of my program freezes until it kill oziexplorer.

Have you tried running all the ozi calls from a separate thread?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Have you tried running all the ozi calls from a separate thread?

I’ve tried it a few different ways. I get the same problem if I updateOzi() from the number crunching thread, or a seperate dedicated thread.

The only time I don’t get the problem is if I call updateOzi() from the EVT_TIMER’s handler, updateClock. In addition to being grossly inefficient (new data only comes in once every 10 - 30 seconds), this makes my gui unresponsive once a second.

I also tried launching a new thread from updateClock, but that only made the timing better. If updateOzi() lasts longer than the period of my timer I get the same old problem.

What I’m imagining is happening is that if another thread is being processed when the ozi calls return, it isn’t sure what to do.

···

On 7/28/06, Christopher Barker < Chris.Barker@noaa.gov> wrote:

Warren Jackson wrote:

I’m making a program that reads data from the serial port, does some

number crunching, and then sends data to my wx gui, as well as another
program (oziexplorer). I’m using a Python wrapper for the oziexplorer api.

The problem I’m running into is that when an event is fired in wx while

the oziexplorer methods are running, oziexplorer permanently freezes,
and the rest of my program freezes until it kill oziexplorer.

Have you tried running all the ozi calls from a separate thread?

-Chris


Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

So far I have found it somewhat difficult to understand what you are
really doing. I understand that you have 3 components (serial
communications, data processor, GUI), but I haven't really seen how you
are plugging them together.

Are you sure that the "ozi" library has been properly wrapped? Is it
sharing memory with other threads? Yeah, threads, but how are the
threads communicating - how is information getting from the serial
libary to/from "ozi" and your GUI, how is information getting from "ozi"
to/from your GUI?

- Josiah

···

"Warren Jackson" <wj@warrenjackson.com> wrote:

>Have you tried running all the ozi calls from a separate thread?

I've tried it a few different ways. I get the same problem if I updateOzi()
from the number crunching thread, or a seperate dedicated thread.

The only time I don't get the problem is if I call updateOzi() from the
EVT_TIMER's handler, updateClock. In addition to being grossly inefficient
(new data only comes in once every 10 - 30 seconds), this makes my gui
unresponsive once a second.

I also tried launching a new thread from updateClock, but that only made the
timing better. If updateOzi() lasts longer than the period of my timer I
get the same old problem.

What I'm imagining is happening is that if another thread is being processed
when the ozi calls return, it isn't sure what to do.

On 7/28/06, Christopher Barker < Chris.Barker@noaa.gov> wrote:
>
> Warren Jackson wrote:
>
> > I'm making a program that reads data from the serial port, does some
> > number crunching, and then sends data to my wx gui, as well as another
> > program (oziexplorer). I'm using a Python wrapper for the oziexplorer
> api.
> >
> > The problem I'm running into is that when an event is fired in wx while
> > the oziexplorer methods are running, oziexplorer permanently freezes,
> > and the rest of my program freezes until it kill oziexplorer.
>
> Have you tried running all the ozi calls from a separate thread?
>
> -Chris
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> NOAA/OR&R/HAZMAT (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
>
>

Josiah Carlson wrote:

Are you sure that the "ozi" library has been properly wrapped?

indeed, i suspect this might be the issue. If threads are blocking each-other, then it sounds like a Global Interpreter Lock (GIL) issue. wxPython has been far more heavily tested than the ozi wrappers, so I'm guess that PyOzi isn't releasing the GIL properly -- but that's just a guess.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Warren Jackson wrote:

My first solution was to stop the timer, run the oziexplorer update, and
then start it again, but I can't start it again outside of the main thread.
And I'm not sure how/if I can access it from a method that is called from
another thread.

You could do it with wx.CallAfter(), if not directly.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov