Pausing until threads are done
aleax at aleax.it
Thu Mar 13 19:45:56 CET 2003
Christos TZOTZIOY Georgiou wrote:
> On Thu, 13 Mar 2003 07:50:52 GMT, rumours say that Alex Martelli
> <aleax at aleax.it> might have written:
>>Don't use the thread module in your application code: it's a very low
>>level module, meant basically as an engine for module threading, which
>>is the one you _should_ be using,
> Why _should_ he? The question mark actually refers to "should", so I am
> asking about the reasoning.
The poster is asking how to perform a task that's elementary with
threading and hard with module thread. If there is no reason to
use thread instead of threading, and there's at least one reason to
use threading instead, then it would be absurd to use module thread
in application-level code.
> Actually, this is not a question directed only to Alex; I have also read
> others posting "don't use thread, you should use threading" or similar
> remarks, but the reasoning seems to be "dogmatic" (in quotes because I
> don't mean it in an offensive way) a la snickers-ads: "Just do it."
There is no "reasoning" involved, when I offer a suggestion whose form
is just "you should do this instead of that" -- it's just advice. When
there are trade-offs I often point them out (over and over AND over
again, since nobody ever seems to bother checking out the archives,
FAQs, etc -- sometimes one does get a bit bored at the 100th repetition
and may end up skipping it). When there is no trade-off, when doing Y
instead of X only has DIS-advantages, then what's the point of listing
the advantages of X each time, particularly when one such obvious
advantage is an immediate answer to the poster's specific question?
> I would offer the following reasoning: "you _should_ use the threading
> module since it offers a much better abstraction of threading, but if
> you feel comfortable using directly the thread module, locks and queues,
> do so."
As long as you continue "...and don't ask on c.l.py how to perform any
task that is even slightly hard in thread and obvious in threading such
as the specific task you're asking about here", I guess such a weird
message might be consistent. But why waste time and energy with the
"if you feel comfortable" provision, when the poster is specifically
asking about how to do something that's hard in one case (the case that
offers no compensating advantages) and easy in the other (the one
that everybody keeps suggesting, for the obvious reason that is IS
the one application code should use, "comfortableness" quite apart)...?
More information about the Python-list