[vtk-developers] Patch to vtkWrapPython.c to make wrapped Python code GIL-friendly

Charl P. Botha cpbotha at gmail.com
Wed Jun 15 18:34:51 EDT 2005


On 6/15/05, Charl P. Botha <cpbotha at gmail.com> wrote:
> On 6/15/05, David Gobbi <dgobbi at atamai.com> wrote:
> > It sounds good.  The only question I have is about observers.  What happens
> > when a python function has been set as an observer for a VTK event?
> > Have you changed the code for vtkPythonCommand::Execute() to do all
> > the proper locking and unlocking?  (Note: vtkPythonCommand is in
> > vtkPythonUtils.cxx).
> 
> Damn, you're good!  I just went for a thinking-break after posting my
> mail and then this dawned on me as well.  I'm going to take a look at
> it now.  I'll post again when I know more.

Okay, it was a bit more complex than I thought.  In order to
re-acquire the lock in the observer, I need the PyThreadState of the
object that is being observed.  I had to inject this into the
vtkPythonCommand instance itself.

Please have a look at the attached three diff files with modifications
to vtkPythonUtil.cxx, vtkPythonUtil.h and vtkWrapPython.c.  Tested on
Linux, VTK threads run concurrently, observers are fired without any
problems.

All comments welcome!

Thanks,
Charl

-- 
charl p. botha http://cpbotha.net/ http://visualisation.tudelft.nl/

c.p.botha ||at|| ewi.tudelft.nl - tu delft work-related email
cpbotha ||at|| cpbotha.net - everything else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPythonUtil.cxx_GIL-Friendly.diff
Type: application/octet-stream
Size: 1676 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20050616/28b6166e/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkPythonUtil.h_GIL-Friendly.diff
Type: application/octet-stream
Size: 711 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20050616/28b6166e/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkWrapPython.c_GIL-Friendly.diff
Type: application/octet-stream
Size: 2418 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20050616/28b6166e/attachment-0005.obj>


More information about the vtk-developers mailing list