Skip to main content

Make C module compatible with gevent at runtime.

Project description

build status pypiv pyversions wheel license

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.

Install from source

greenify module is installed using setuptools or pip:

python setup.py install

or:

pip install greenify

Usage

  1. Active greenify before initiate environment:

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

    assert greenify.patch_lib('/usr/lib/libmemcached.so')
  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.

License

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

Project details


Download files

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

Source Distribution

greenify-0.5.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

greenify-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl (153.7 kB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

File details

Details for the file greenify-0.5.0.tar.gz.

File metadata

  • Download URL: greenify-0.5.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for greenify-0.5.0.tar.gz
Algorithm Hash digest
SHA256 c0c407839e6d9d1974dca3ba91d4b21e4cdda08ac35caebc58a349b646274568
MD5 9eaea723f8283366cfbfee3612bd7e13
BLAKE2b-256 43a04b9ac3becaa52b1b8c1be4abef4f5f4b4c3cc702669adb94b41d08ce5287

See more details on using hashes here.

File details

Details for the file greenify-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.5.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 087711c1b24b47ab86bd7ceeaf9a93f4896b4da072bc9a1875c7f206bdf31e55
MD5 5f86046deca9cd2e94195133261a3e09
BLAKE2b-256 742f5159daec5e839630698c53a762b9a0e5dd347a7c5189545e620d8d188dde

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page