[Tutor] threading in python 2.7 - 2nd version
ranceh at gmail.com
Mon Jan 5 06:19:33 CET 2015
Thanks to the advice from Joseph and Alan, I hacked a quick python script
which demonstrates my problem more accurately.
Its not board specific as was my last code. This sample works the same on
my pcduino as it does on my desktop.
#threading problem example
threads = 
exitFlag = 0
while not exitFlag:
print "exitFlag value: ", exitFlag
exitFlag = 1
print "Exit flag value: ", exitFlag
for t in threads:
my_thread = threading.Thread( target = threadloop, args = () )
keypress = raw_input("Press a key and hit Enter to exit\n")
the thread driven loop doesn't ever see the fact that the exitFlag as
changed, based on the output to screen.
Be warned, this code gives you an infinite loop, so be sure to run it in a
terminal you can kill without impacting other work you are doing.
There are many ways to work with theads. Class definitions, etc. The
thread and threading modules.
I've tried several and get the same results.
What do I need to do to get the thread to stop based on the value of
More information about the Tutor