-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
35 lines (28 loc) · 1.06 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
=======
qThread
=======
qThread provides an simplified and safe way to stop long running
threads. Typical uses often look like this::
# Test / Usage of the stoppable thread
class MyThreadingClass(StoppableThread):
def __init__(self, a):
super(MyThreadingClass, self).__init__()
self.a = a
self.b = "World"
self.delay = .5 # seconds
def startup(self):
# Overload the startup function
print "My Thread Starting Up..."
def cleanup(self):
# Overload the cleanup function
print "My Thread Is Shutting Down..."
# Close files, ports, etc...
time.sleep(4)
print "Cleanup Complete!"
def mainloop(self):
# Some routine to be called over and over
# ie: reading ports or sockets
print self.a + " " + self.b
# Throttling needs to be done here if the
# primary function is not blocking
time.sleep(self.delay)