[Python-Dev] Python Interpreter Thread Safety?
Evan Jones
ejones at uwaterloo.ca
Fri Jan 28 14:17:07 CET 2005
Due to the issue of thread safety in the Python memory allocator, I
have been wondering about thread safety in the rest of the Python
interpreter. I understand that the interpreter is not thread safe, but
I'm not sure that I have seen a discussion of the all areas where this
is an issue. Here are the areas I know of:
1. The memory allocator.
2. Reference counts.
3. The cyclic garbage collector.
4. Current interpreter state is pointed to by a single shared pointer.
5. Many modules may not be thread safe (?).
Ignoring the issue of #5 for the moment, are there any other areas
where this is a problem? I'm curious about how much work it would be to
allow concurrent execution of Python code.
Evan Jones
Note: One of the reasons I am asking is that my memory allocator patch
is that it changes the current allocator from "sort of" thread safe to
obviously unsafe. One way to eliminate this issue is to make the
allocator completely thread safe, but that would require some fairly
significant changes to avoid a major performance penalty. However, if
it was one of the components that permitted the interpreter to go
multi-threaded, then it would be worth it.
More information about the Python-Dev
mailing list