[chimera-dev] thread-communication

Daniel Greenblatt dan at cgl.ucsf.edu
Sun Oct 12 22:38:22 PDT 2003


On Friday, October 10, 2003, at 02:34 AM, Lars Kunert wrote:

> Hi!
>
> When my plugin talks with chimera, it does so from a foreign thread.
> I am currently using an approach I have "stolen" from the
> DelphiViewer-plugin
>
> which fetches the
>
> see __init__.py>>    self.parent = chimera.tkgui.app
>
> gui-thread
> and places a
> callback
>
> see __init__.py>>                          self.parent.after(100,
> self.CheckProcess)
>  I have added a queue in between, so my extension feeds the queue, 
> which
> the gui-thread is frequently asked to process (and empty)

If I understand your problem correctly, it seems like what your doing 
here can alternatively be accomplished by using Chimera's trigger 
mechanism.  I'm not sure if you're familiar with Chimera's triggers. 
Briefly, they are a way for Chimera and extensions to register interest 
in a certain event, and to specify that certain callbacks should be 
invoked when that event happens. There are three steps to using the 
triggers:

1) Create a triggerset and add a trigger. This is just a name to 
uniquely identify the event.
ts = TriggerSet.TriggerSet()
ts.addTrigger("Check Process")

2) add a handler.  This handler will be invoked when the trigger is, 
ummmm, triggered. "Check Process" is the name of the trigger to 
register the handler with, self.processChanges is the function to call 
when the trigger is invoked, and data is an arbitrary argument
ts.addHandler("Check Process", self.processChanges, data)

3) Actually invoke the trigger. All the callbacks associated with the 
trigger will be called in the order they were registered. "Check 
Process" is the name of the trigger to activate, and additionalData is  
any data that should be passed to the function.
ts.activateTrigger("Check Process", additionalData)

For more information on chimera's trigger mechanism, see the example at 
the top of CHIMERA/share/chimera/triggerSet.py				

> What I actually want to know is if there some kind of functionality 
> like
> this already in chimera:
>
> The programmer of the DelphiViewer suspected something like that in the
> trigger-stuff
>
> __init__.py:                    # modify this to use the
> chimera.triggerSet?
>
> but I can not find any threading stuff there, just plain
> single-thread-callbacks......or am I wrong

Chimera only uses one thread, although some extension to Chimera do use 
multiple threads, and everything in Chimera is compiled to be 
threadable. All the callbacks that happen in Chimera originate from a 
single event loop.

I hope this helps, and please feel free to email with any more 
questions, or if any of this requires further clarification.

Dan Greenblatt
Computer Graphics Lab
University of California, San Francisco
dan at cgl.ucsf.edu



More information about the Chimera-dev mailing list