Is python is fully thread safe

François Pinard pinard at iro.umontreal.ca
Sat Jul 31 09:06:44 EDT 2004


[Dave Brueck]

> As to what the Python documentation needs to say (and, in the end,
> perhaps it already does this well enough), I'd think it needs to make
> a few things clear:

> 1) Accessing the same Python object from multiple threads from Python
> code won't corrupt the internals of the interpreter.

> 2) Modules/functions that are just plain not thread-safe should be
> marked as such (e.g. the fpectl module).

> Beyond that, can you think of anything else?

If the absence of an explicit notification for a library module was
meaning that the module is thread-safe, it would be a great relief
indeed.  (Of course, this convention itself should be clearly stated,
along with your note '1)' above.)

For those being anal about thread-safety of small operations, maybe that
the documentation might usefully mention the usual `import dis' trickery
to explore how many op-codes implement various operations.  With maybe
some due warning that implementation may (or may not) change for some
particular operations.

Best would be that the reference manual present thread-safety notes, for
operations, in the same way that the library manual present them for
modules.  That is, any operation with no explicit notification would
mean that this operation is thread-safe (unless overridden, of course).

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard



More information about the Python-list mailing list