I have two threads in my PyGTK app:
- the main thread which runs the GTK loop and does all the GUI stuff
- another thread which handles network requests, etc.
I need to have the second thread get some information from the first thread, so I call:
variable = None
gobject.idle_add( function_in_main_thread, variable )
In the main thread I have:
def function_in_main_thread( variable ):
variable = 1
The problem is that the variable in the second thread never gets set. It's value remains at None. So how can I get the main thread to actually modify the variable in the other thread?
Note: I have some thread synchronization code in the script in case anyone is concerned about modifying variables in other threads. I omitted it from this example because I felt it really didn't apply to the real issue.