[Baypiggies] multithreading question

Alex Martelli aleax at google.com
Wed Sep 17 23:33:35 CEST 2008


On Wed, Sep 17, 2008 at 1:27 PM, Stephen McInerney
<spmcinerney at hotmail.com> wrote:
> Alex,
>
> Is there a need to more clearly document which Python modules and fns
> (in the CPython implementation) are threadsafe?
> This sort of information is impossible to find.

You can safely assume that no module is thread-safe unless it claims
it is.  At http://docs.python.org/lib/node424.html for example you can
read:
"""
14.5.9 Thread Safety

The logging module is intended to be thread-safe without any special
work needing to be done by its clients. It achieves this though using
threading locks; there is one lock to serialize access to the module's
shared data, and each handler also creates a lock to serialize access
to its underlying I/O.
"""
and at http://docs.python.org/lib/module-Queue.html:
"""
especially useful in threads programming when information must be
exchanged safely between multiple threads. The Queue class in this
module implements all the required locking semantics.
"""

How is this info hard to find?


Alex


More information about the Baypiggies mailing list