Thread allready started ??

Chris Liechti cliechti at
Tue Oct 1 20:57:47 CEST 2002

"Thomas Weholt" <2002 at> wrote in
news:QXlm9.28399$sR2.488144 at 

> I'm trying to create a TaskManager, starting a bunch of threads on
> given intervals. The problem is that I get an error "Thread allready
> started". This TaskManager is running inside a threaded webserver, so
> I don't know if this is the best way to have a set of tasks repeated
> over time on given intervals. If anybody has any pointers I'd
> appreciate it. 

a Thread can only be started once. if you need it again, you need to create 
a new instance.

> NB! I want a Manager-thread starting/stopping sub-threads, not just a
> simple while loop.

you'll probably have a while loop ;-)

one way:
make supend/resume methods (untested):

class T(threading.Thread)
    	def __init__(self):
    	    	self.suspended = threading.Event()
 = 1
    	def suspend(self):
    	def resume(self):
    	def stop(self):
 = 0
    	def run(self):
    	    	    	work(with, you, data)
    	    	    	self.running.wait()    	#will return if event is set

there are many other ways...


Chris <cliechti at>

More information about the Python-list mailing list