Thread allready started ??
cliechti at gmx.net
Tue Oct 1 20:57:47 CEST 2002
"Thomas Weholt" <2002 at weholt.org> wrote in
news:QXlm9.28399$sR2.488144 at news4.ulv.nextra.no:
> 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 ;-)
make supend/resume methods (untested):
self.suspended = threading.Event()
self.active = 1
self.active = 0
work(with, you, data)
self.running.wait() #will return if event is set
there are many other ways...
Chris <cliechti at gmx.net>
More information about the Python-list