Counting Threads
David Poundall
david at jotax.com
Thu Oct 27 19:38:36 EDT 2005
First time I have used thread locking. This seems to work but is it
correct?
from threading import Thread, Event, Lock
.
.
.
def launch(self, ThreadTitle, SubToLaunch, SubsArgs=(),
SubsKwargs={}, AsDaemon=True):
my_lock = Lock()
my_lock.acquire()
try:
# ---------------------
t = Thread(target=SubToLaunch, args = SubsArgs, kwargs =
SubsKwargs)
t.setDaemon(AsDaemon)
t.start()
self.Threads[len(self.Threads)] = t # Stash the
thread in an instance local
# ---------------------
ServerThreads.threadcount += 1
finally:
my_lock.release()
.
.
.
More information about the Python-list
mailing list