Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Make C module compatible with gevent at runtime.

Project Description

greenify can make Python extension modules having network operations in C code to be compatible with gevent.

greenify uses the Dynamic Function Redirecting technique same as ELF-Hook to patch blocking network operations at runtime, without the need modify the original modules.

Currently greenify only supports ELF format modules, and is tested on Linux.

Build status

  • Branch master :

Install from source

greenify module is installed using setuptools or pip:

python install


pip install greenify


  1. Active greenify before initiate environment:

    import greenify
  2. Make sure the dynamic module(e.g. libmemcached) is patched before using:

    assert greenify.patch_lib('/usr/lib/')
  3. Import and use the corresponding module, which is now gevent compatible.

Thread Safety

Once activated, the green C functions will, on potentially blocking operation, pass control to gevent’s main event loop, which may switch to other ready greenlet which is also in one of the green functions. So, make sure your C code can handle this kind of execution pause and resume. A thread safe program usually is ready for greenify, but remember that all the switches happen in a single thread.


greenify is written and maintained by douban and is licensed under New BSD license.

Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
greenify-0.3.2-cp27-cp27m-manylinux1_x86_64.whl (103.5 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Nov 18, 2016
greenify-0.3.2-cp27-cp27mu-manylinux1_x86_64.whl (103.6 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Nov 18, 2016
greenify-0.3.2-cp35-cp35m-manylinux1_x86_64.whl (111.8 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Nov 18, 2016
greenify-0.3.2.tar.gz (9.3 kB) Copy SHA256 Checksum SHA256 Source Nov 18, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting