theads & global namespaces
Taylor.Anderson at p98.f112.n480.z2.fidonet.org
Wed Jun 30 12:06:01 CEST 1999
From: Taylor Anderson <andersdt at notes.cba.ufl.edu>
I am trying to share globals between threads. Is is possible for me to
share globals between threads that call functions from different
modules? Thus far I have had little success. I ask this question
because I would prefer not to put all my code in one module.
For example, I have 2 .py files: a.py and b.py. b.py contains the
function ('foo()') to be executed under the new thread, as well as the
global variable 'x'. a.py contains the call to
start_new_thread(foo,()). a.py also tries to use the global variable x.
x = 0
x = x + 1
from b.py import *
if __name__ == '__main__':
if x != 0:
So far, my code in a.py does not detect any change in x. Any
suggestions for a workaround?
More information about the Python-list