On Threading vs. Processing
Writing multi-threaded applications in Python is often a headache because of
the Global Interpreter Lock - only one Python thread can run at any given
moment, which makes multi-threading useful only in the case where all modules
but one actually run C code. However, thanks to the impressive new Python
Magazine, I’ve stumbled across a package called
processing, paraphrasing python’s built-in threading package. Essentially,
the package provides an API identical to Python’s threading, but uses processes
and pipes (or other mechanisms on non-posix operating systems) instead. What
the magazine does not cover is the fact that this can also benefit GUI
applications; updating a progressbar in the application doesn’t need to slow
down heavy computations being done in a separate thread. To show how easy the
integration is, take the following example which shows usage of either threads
or processes at the user’s choice:
