[Tutor] Threads
Gonçalo Rodrigues
op73418 at mail.telepac.pt
Mon Nov 15 23:00:26 CET 2004
Terry Carroll wrote:
> On Sun, 14 Nov 2004, Kent Johnson wrote:
>
>
>>I'm starting to think there is a cultural bias against threads in the
>>python community.
>
>
> I think there's a bias against threads in the tutorial mailing list, which
> is kind of understandable. It's a big leap in writing and debugging. I
> suspect that most programmers who are looking for help, and who are
> proficient enough to use threads, would probably be hitting the
> comp.lang.python newsgroup, rather than python-tutor.
>
Agreed. Threads can seem simple but they have associated all the
shenanigans of synchronization and deadlocking, starvation, race
conditions, etc. And all these problems can be *very* hard to debug.
[snip]
> What's the ordinary way of telling a thread that it's no longer needed?
>
Use the queue to pass an object that the thread can recognize as an
order to shut down. Upon reception the thread can gracefully shut down,
releasing all resources, etc. There is no way of this moment to kill
threads from the outside (which is always a last option anyway -- a sort
of "look, if you don't behave I'll kill you ok?") so you must build your
framework with this kind of cooperation in mind.
With my best regards,
G. Rodrigues
More information about the Tutor
mailing list