Multiprocessing Gevent Extension
HIC SUNT DRACONES!!!
This code is extremely experimental (pre-pre-alpha). There is very little testing, lots of things are in flux, some platforms don’t work at all.
DO NOT use in production. This code may crash your server, bankrupt your company, burn your house down and be mean to your puppy. You’ve been warned.
Due to internal implementation, multiprocessing (MP) is unsafe to use with Gevent even when monkey-patched. Namely, the use of OS semaphore primitives and inter-process IO in MP will cause the main loop to stall/deadlock/block (specific issue depends on the version of CPython).
- Identify all places where blocking occurs and where it may stall the loop.
- If blocking occurs on a file descriptor (FD), try to convert the file descriptor from blocking to non-blocking (sockets/pipes/fifos, sometimes even files where, rarely, appropriate) and replace blocking IO functions with their gevent non-blocking equivalents.
- If blocking occurs in a Python/OS primitive that does not support non-blocking access and thus cannot be geventized, wrap all blocking access to that primitive with native thread-pool-based wrappers and call it a day (while fully understanding that primitive access latency will increase and raw performance may suffer as a result).
- If you are really brave and have lots of free time on your hands, completely replace a standard blocking Python non-FD-based primitive with implementation based on an FD-based OS primitive (e.g. POSIX semaphore => Linux eventfd-based semaphore for kernels > 2.6.30).
- Due to launching of separate processes in MP, figure out how, when, and whether to monkey patch spawned/forked children and grandchildren.
The package is hosted on PyPi.
For stable version:
pip install geventmp
For unstable version:
pip install --pre geventmp
Once installed, geventmp will activate by default in the below stanza.
from monkey import patch_all patch_all()
If you would like geventmp to not activate by default, either do not install it or explicitly disable it:
from monkey import patch_all patch_all(geventmp=False)
That’s it - there are no other flags, settings, properties or config values so far.
All claims of support may not be real at all. You’re welcome to experiment. See warnings on top.
- Linux, possibly Darwin.
- CPython 2.7, 3.5, 3.6, 3.7… maybe.
- Implement CI/CD once we figure out how Gevent Issue #1448 is going to go.
- Test on CPython 2.7, 3.5, 3.6, 3.7, 3.8, PyPys etc.
- Monkey patch Windows to the extent possible.
- Test and fix Darwin if required.
- Lots of applications use Billiard for multiprocessing instead of stock Python package. Consider monkey patching Billiard if detected.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size geventmp-0.0.1.dev2-py2.py3-none-any.whl (15.3 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View hashes|
Hashes for geventmp-0.0.1.dev2-py2.py3-none-any.whl