The reliability of python threads

Chris Mellon arkanes at gmail.com
Wed Jan 24 19:36:46 CET 2007


On 24 Jan 2007 18:21:38 GMT, Nick Maclaren <nmm1 at cus.cam.ac.uk> wrote:
>
> In article <mailman.3095.1169659417.32031.python-list at python.org>,
> "Chris Mellon" <arkanes at gmail.com> writes:
> |> > |>
> |> > |> Does anyone have any conclusive evidence that python threads/locks are
> |> > |> safe or unsafe?
> |> >
> |> > Unsafe.  They are built on top of unsafe primitives (POSIX, Microsoft
> |> > etc.)  Python will shield you from some problems, but not all.
> |> >
> |> > There is precious little that you can do, because the root cause is
> |> > that the standards and specifications are hopelessly flawed.
> |>
> |> This is sufficiently inaccurate that I would call it FUD. Using
> |> threads from Python, as from any other language, requires knowledge of
> |> the tradeoffs and limitations of threading, but claiming that their
> |> usage is *inherently* unsafe isn't true. It is almost certain that
> |> your code and locking are flawed, not that the threads underneath you
> |> are buggy.
>
> I suggest that you find out rather more about the ill-definition of
> POSIX threading memory model, to name one of the better documented
> aspects.  A Web search should provide you with more information on
> the ghastly mess than any sane person wants to know.
>
> And that is only one of many aspects :-(
>

I'm aware of the issues with the POSIX threading model. I still stand
by my statement - bringing up the problems with the provability of
correctness in the POSIX model amounts to FUD in a discussion of
actual problems with actual code.

Logic and programming errors in user code are far more likely to be
the cause of random errors in a threaded program than theoretical
(I've never come across a case in practice) issues with the POSIX
standard.

Emphasizing this means that people will tend to ignore bugs as being
"the fault of POSIX" rather than either auditing their code more
carefully, or avoiding threads entirely (the second being what I
suspect your goal is).

As a last case, I should point out that while the POSIX memory model
can't be proven safe, concrete implementations do not necessarily
suffer from this problem.



More information about the Python-list mailing list