I want change global variable in module1.py by module2.py.
module1.py
#!/usr/bin/env python
import threading
import module2 as module22
import time
values=True
def main():
print "m"
def thread():
while(values):
print "moduel1"
time.sleep(0.50)
print "END PROGRAM"
def change():
print "change"
values=False
if __name__ == "__main__":
t2=threading.Thread(target=module22.main())
t1=threading.Thread(target=thread())
t1.start()
t2.start()
t1.join()
t2.join()
module2.py
#!/usr/bin/env python
import module1 as module11
def main():
print "module2"
module11.change()
if __name__ == "__main__":
main()
When I run sudo python module1.py:
Result is here
module2
change
moduel1
moduel1..
I want get result
module2
change
END PROGRAM
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…