Why won't my thread terminate?

Andrew Henshaw andrew.henshaw at mail.com
Fri May 23 08:12:12 EDT 2003


<posted & mailed>

Dfenestr8 wrote:

> Hello.
> 
> I read that a thread terminates when its run() method finishes.
> 
> I'm trying to terminate  the thread below by changing the value upon which
> a while loop runs to 0.
> 
> But every time I try and get the thread running again, using the start()
> method, I get:
> 
> "AssertionError: thread already started"
> 
> What am I doing wrong?
...snip...
It looks like you really want a worker thread that is idle when it has no
task.  Look at the Queue module. I'd structure my code such that the worker
waits on job requests from a master using a queue.  While waiting on a job,
the worker will sleep.  The master could also use the queue to indicate
when the thread should truly terminate.

--Andy





More information about the Python-list mailing list