sleep?
Peter Hansen
peter at engcorp.com
Fri Jan 25 19:52:49 EST 2002
Jason Orendorff wrote:
>
> Peter Hansen wrote:
> > You don't want to use thread. You might want to use threading.
>
> Why does everyone keep knocking thread?
>
> >>> import thread, time
> >>> def f():
> ... time.sleep(5)
> ... print 'function ran'
> ...
> >>> thread.start_new_thread(f, ())
>
> How can you not love that? Brief, simple, and clear.
Nice for a toy function but I've never met a thread in
Python which didn't benefit by being subclassed once
or twice to provide some general functionality such as
robust catching of exceptions and a way of stopping them
nicely with a thread.stop() call (in my own code, that is).
Matter of personal choice in my case, but I admit I
was originally swayed by the _many_ comments I saw
in this group dissing the thread module and promoting
the threading module. Given the sources in question,
I never had reason to question their advice. I'll
pay more attention to any responses this time...
-Peter
More information about the Python-list
mailing list