Thread Safety

ykingma at accessforall.nl ykingma at accessforall.nl
Sat Oct 4 13:50:09 EDT 2003


"Martin v. Löwis" wrote:

> MetalOne wrote:
>> Are atomic operations thread safe in Python?
> 
> I don't understand the question. Atomic operations, by nature, can
> either completely succeed or completely fail - otherwise it would not
> be atomic. This is independent of Python.
> 
> In general, you cannot cause inconsistency of Python's internal
> representation of objects by pure Python code executed in multiple
> threads, so Python itself is thread-safe.

For the namespaces in Jython this 'Python internal thread safety'
is handled by the Java class:

http://www.jython.org/docs/javadoc/org/python/core/PyStringMap.html

which has almost all of it public methods Java synchronized:

http://cvs.sourceforge.net/viewcvs.py/jython/jython/org/python/core/PyStringMap.java

Thinking about it: is this the Jython parallel of CPython's
Global Interpreter Lock, the famous GIL?

Regards,
Ype

-- 
email at xs4all.nl




More information about the Python-list mailing list