[vtk-developers] Calling UpdateProgress from multiple threads

Mathieu Malaterre mathieu.malaterre at gmail.com
Mon Jun 16 07:47:41 EDT 2008


Just FYI.

I found the solution in the implementation of vtkImageProgressIterator:

  if (!this->ID)
    {
    if (this->Count2 == this->Target)
      {
      this->Count += this->Count2;
      this->Algorithm->UpdateProgress(this->Count/(50.0*this->Target));
      this->Count2 = 0;
      }
    this->Count2++;
    }

Indeed this was clearly documented one should call UpdateProgress from
thread #0 :)

-Mathieu

On Wed, Jan 9, 2008 at 6: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 ?
>
> Thanks,
> --
> Mathieu
>



-- 
Mathieu



More information about the vtk-developers mailing list