The reliability of python threads

Chris Mellon arkanes at gmail.com
Wed Jan 24 18:23:33 CET 2007


On 24 Jan 2007 17:12:19 GMT, Nick Maclaren <nmm1 at cus.cam.ac.uk> wrote:
>
> In article <mailman.3092.1169657938.32031.python-list at python.org>,
> "Carl J. Van Arsdall" <cvanarsdall at mvista.com> writes:
> |> Hey everyone, I have a question about python threads.  Before anyone
> |> goes further, this is not a debate about threads vs. processes, just a
> |> question.
> |>
> |> With that, are python threads reliable?  Or rather, are they safe?  I've
> |> had some strange errors in the past, I use threading.lock for my
> |> critical sections, but I wonder if that is really good enough.
> |>
> |> 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.



More information about the Python-list mailing list