How to create Stopable thread in python:- just copy and paste:) Learning:- #!/usr/bin/python2 import threading import time def myfunction(say): print "my first thread is runnning" while 1: print say time.sleep(1) thread = threading.Thread(target=myfunction,args=("hello sir",)) print "Thread is alive: ",thread.isAlive() t = threading.Event() #must after instance is created thread.daemon = True #must after threading.event and before start the event thread.start() #start the thread time.sleep(1) print "Check flag: ",t.isSet() #Check flag before stopping time.sleep(1) ...
A startup blog to learn basics of robotics programming.