Jython Concurrency
log in to bookmark this presentaton
Abstract
Jython implements the Python language, but we leverage the underlying Java platform to provide an opionated alternative to CPython in our support of concurrency.
Because of the GIL and related infrastructure, CPython cannot use a model in which threads perform concurrent computation defined in Python on shared objects in the same process. (Of course, there are workarounds, such as multiprocessing or using C extensions.)
In contrast, there's no GIL in Jython. Jython instead embraces threads, provides extensive support for managing their execution and coordination through standard Java platform functionality (java.util.concurrent), and threaded code works well with Jython's implementation of standard mutable collection types. Lastly, the underlying JVM provides extensive instrumentation as well as the ability to set a variety of parameters, including choice of GC. There are also the inevitable pitfalls that might be seen in complex architectures, such as around the use of ClassLoaders.
This talk will go into a detailed discussion of some of the interesting ramifications of these design points and how they can be effectively applied to write concurrent code, as illustrated through a variety of short examples.