Kurt Mueller wrote:
Within the threads I collect some data,
OK
make some numpy calculations,
OK
and then I update the plot with the
wx.lib.plot.PlotCanvas.Draw() method.
Does that makes trouble?
Probably, yes -- it's going to be making wx calls -- at least 1, anyway. if you are using wxAgg, then it is doing the drawing in its own code, to an agg buffer in memory, then copying that over to a wxBitmap and blitting it to the screen. Those past two steps are not thread-safe.
I don't know that there is a way to get MPL do do most of its drawing in a thread, then do the final blit separately -- it would take some poking into the wx back-end code, which is a bit messy.
you might try doing your calculations in a separate thread, then calling MPL from the main thread, and see how that works for you.
The other thing is, that an update for the plot takes about 0.1[s],
so it is not a "long running task".
If I start 10 update tasks every second, then there is always one thread
running.
How does threading behaves if there is always one thread ready for running,
and there is never an idle situation?
That should work -- the whole point of threads is that they run in parallel ,they are not waiting for an idle state, or one to finish before the next one starts. However, there is the issue of the global interpreter lock (GIL). In Python, if operations may not be thread safe, they ca lock the interpreter to assure that they don't et stomped on by another thread -- this is complicated, and I have no idea when it is invoked, but it does allow one thread to freeze of the interpreter in some situations -- maybe that's happening here, but I'd try the above first.
Of course, if you are already doing that, then we'll probably need a
sample app:
See MakingSampleApps - wxPyWiki for more info.
Jouh, I was afraid of that.
The app has about 5000 lines of code.
But...
you don't need all of it at all -- just make a simple app that does a bunch of MPL plotting and see what you get -- asking on the MPL list might be helpful too.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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