python-safethread


Threading extensions to the Python Language

python-safethread is a large modification of CPython intended to provide safe, easy, and scalable concurrency mechanisms. It focuses on local concurrency, not distributed or parallel programs.

Note: As an implementation, python-safethread is dead. It is not worth the effort to continue rewriting CPython to have a true tracing GC.

However, the semantics presented are still viable and I intend to reuse them in future projects.

Some major features: * Exceptions from threads propagate naturally and cause the program to shut down gracefully. * No memory model is necessary. All mutable objects are safely contained with monitors (similar to Concurrent Pascal's monitors, but different from Java's monitors), or otherwise provide explicit semantics. * Deadlocks are detected and broken automatically. * Finalization is thread-safe (and uses a much simpler mechanism at a low-level.) * Most existing single-threaded code will continue to be correct (and in good style) when used amongst threads. Some boilerplate may be necessary to share module and class objects between threads. * The GIL is removed. Each additional thread should run at or near 100% throughput. However, the base (single-threaded) throughput is only around 60-65% that of normal CPython, so you'll need several threads for this to be worthwhile.

Branching | Finalization | Monitors | Shareability | Status

A large chunk of my design rationale is given on DeadlockFallacy.

Discussion may be done on the mailing list, http://groups.google.com/group/python-safethread, as well as in #python-safethread on Freenode. Or if you prefer, you may contact me directly. rhamph@gmail.com

Project Information