threads only called once?

Steve Holden sholden at holdenweb.com
Tue Aug 6 10:06:19 EDT 2002


"Ian McMeans" <imcmeans at telus.net> wrote
> Can threads only be called once?
>
> >>> myThread.start()
> run was called
> >>> myThread.isAlive()
> 0
> >>> myThread.join()    # returns instantly
> >>> myThread.start()
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File "F:\Python22\lib\threading.py", line 384, in start
>     assert not self.__started, "thread already started"
> AssertionError: thread already started
>
> Why can't the thread be started again if it's not alive (ie not running)?
Am
> I missing something here?
>
Yes: the part of the manual that says:

"""start()
Start the thread's activity.
This must be called at most once per thread object. It arranges for the
object's run() method to be invoked in a separate thread of control. """

regards
-----------------------------------------------------------------------
Steve Holden                                 http://www.holdenweb.com/
Python Web Programming                http://pydish.holdenweb.com/pwp/
-----------------------------------------------------------------------









More information about the Python-list mailing list