[Paraview] python plugin custom dialog causes paraview to hang

m.c.wilkins at massey.ac.nz m.c.wilkins at massey.ac.nz
Sun Oct 17 15:35:21 EDT 2010


Hi,

> Are you working from a paraview installer, or compiling paraview yourself?  I

downloaded stock standard 3.8.1 for Windows.

> was able to reproduce the linux bug (by putting a 'print "hello"' at the end)
> and then solve it by commenting out two lines in ParaView/Qt/Python/
> pqPythonShell.cxx.  Just search for the lines with "processEvents" and comment
> them out and then recompile.

thanks.  Windows is not my platform of choice, i've never successfully
compiled up paraview with visual studio before.  anyway now I have a
lot more motivation, and i do have the Paraview Guide with
instructions, so I will give it a go.

> I'll try to explain it why this fixes the problem-
> 
> Before paraview executes the python script it acquires a lock.  The lock is
> part of the python C api to help make things thread safe ( http://
> docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock ).
>   Paraview doesn't use threads, but it uses multiple python interpreters, and
> each interpreter has its own "thread state".  So before any code is executed by
> the paraview python shell, the shell acquires the lock to activate its
> interpreter.
> 
> Next, the python script hits a print statement which sends an output string to
> the paraview python shell.  The shell calls processEvents so that the widget
> has an opportunity to repaint itself (make the text appear on your screen)
> without having to wait for the entire python script to complete execution.  The
> problem is that during processEvents, the events generated by calling show on a
> PyQt widget are also processed.  While processing these events, PyQt tries to
> acquire the lock itself, fails, and then waits- paraview hangs because this all
> happens in the same thread.  The fix is either to comment out the processEvents
> call in pqPythonShell.cxx, or release the lock before calling processEvents and
> then reacquire it afterward.

Thanks Pat.  I think I follow.  Although I'm not sure what affect not
calling processEvents will have on my widget.  Will it never have a
chance to update?

> I have never tested PyQt+Paraview on Windows, there may be further bugs.  Also,
> there could be other scenarios where the paraview python shell and PyQt fight
> over the lock.

Ok, thanks.

> Hope this helps a bit!

Indeed it does, it is nice to know I'm not trying to figure this out
all by myself.

Matt



More information about the ParaView mailing list