[vtk-developers] Re: Calling UpdateProgress from multiple threads

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Jan 9 12:31:10 EST 2008


On Jan 9, 2008 5:11 PM, Mathieu Malaterre <mathieu.malaterre at gmail.com> wrote:
> Hi there,
>
>   I am getting a seg fault from a python script when I am observing a
> ProgressEvent
>
> ==20066== Thread 2:
> ==20066== Invalid read of size 4
> ==20066==    at 0x403232A: sem_post@@GLIBC_2.1 (in
> /usr/lib/debug/libpthread-2.5.so)
> ==20066==    by 0x80B0D53: PyEval_ReleaseLock (in /usr/bin/python2.4)
> ==20066==    by 0x80DDB20: PyGILState_Release (in /usr/bin/python2.4)
> ==20066==    by 0x45C7AB4: vtkPythonCommand::Execute(vtkObject*,
> unsigned long, void*) (vtkPythonUtil.cxx:2016)
> ==20066==    by 0x483C0DF: vtkSubjectHelper::InvokeEvent(unsigned
> long, void*, vtkObject*) (vtkObject.cxx:547)
> ==20066==    by 0x483C18E: vtkObject::InvokeEvent(unsigned long,
> void*) (vtkObject.cxx:713)
> ==20066==    by 0x4E67E6A: vtkAlgorithm::UpdateProgress(double)
> (vtkAlgorithm.cxx:115)
>
>
>   Calling the very same filter from C++ is running perfectly fine. I
> did put the critical section (call to UpdateProgress) in between a
> mutex lock. Is there something I should pay attention when using
> command/observer calling a python function ?


After reading:

http://docs.python.org/api/threads.html

I tought that I was simply missing a call to PyEval_InitThreads(),
which can also be found for vtkpython. But adding that function call
makes python act as if it hung !

The only hack I found so far is to remove the call to

  // PyGILState_STATE state = PyGILState_Ensure();
and
  // PyGILState_Release(state);

So I am stuck...

Suggestion anyone ?
-- 
Mathieu



More information about the vtk-developers mailing list