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

Charl P. Botha cpbotha at gmail.com
Mon Jun 20 10:33:20 EDT 2005


Hi there Prabhu,

On 6/19/05, Prabhu Ramachandran <prabhu_r at users.sf.net> wrote:
> Well, thread-safety issues come with the territory and once you start
> using threads you have to keep it in mind anyway.
> 
> Here is a simple scenario which I would think would be fairly typical
> with just two threads.  Imagine that the GUI is in the main thread
> (t0) and long-running VTK tasks run in a separate thread (t1).  Lets
> say you'd like the UI to be notified when the long-running task does
> something, like say a ProgressEvent.  Clearly, you'll want to give the
> user feedback of the progress and therefore a natural way to do this
> would be to listen for ProgressEvents in an observer running in t0 and
> not t1.  So you have an observer in t0 listening to an object running
> in t1.  I'd think this would be a common use case and it is important
> that this works.  If you wish to disallow more than 2 threads, that is
> fine.  But I would think the above does need to be supported.
> 
> Sorry to be such a pain, but you asked for comments. :-)

Damn me! ;)  For communicating between threads, there are proven
existing constructs, such as for example the thread-safe Queue in
Python.  In wxWidgets, the standard and excepted pattern is to pass
EVT_MESSAGEs from the worker thread to the UI thread.  IMHO, it's
better to use these things for inter-thread communication, as they
were designed from the get-go with this in mind and the VTK observers
weren't.

How many (STABLE!) multi-threaded C++ VTK applications communicate
between threads with VTK observers?

I'm not convinced yet, and remain stubbornly with my idea of keeping
observers and the vtk objects that they observe in the same thread. 
If a user wants inter-thread communication, she should use the
data-structures and mechanisms that were designed for this purpose.

Cheerio,
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



More information about the vtk-developers mailing list