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.4.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distributions

greenify-0.4.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (211.1 kB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

greenify-0.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (214.2 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

greenify-0.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (201.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

greenify-0.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (172.9 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

greenify-0.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (172.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

File details

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

File metadata

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

File hashes

Hashes for greenify-0.4.3.tar.gz
Algorithm Hash digest
SHA256 e5e65b6abb43cb49fe12eae0e90bd634737857613e5a3f6ee3a2a2b8518d9a8c
MD5 cce3864e6b32f6bac4fe19ce485df924
BLAKE2b-256 ac19df25998ee39e3a20a4e518b0a0d06ad6a50b9892e17d1fc52280c5abfe23

See more details on using hashes here.

File details

Details for the file greenify-0.4.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.4.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba70351d2e3003a8d85a2ecf4a7c6a135bd664f5dc2210ef68e2a42e2a237a68
MD5 8cfcea0b0cbf9951f47e4e391162d491
BLAKE2b-256 9223a232e5a880117a02113271254e00a222c137227caaf33d94b6c4e21c97e9

See more details on using hashes here.

File details

Details for the file greenify-0.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.4.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d842243a810e3a116349fb42cef27e2dcf6b06c683e1360316137fae1392ac13
MD5 973c972190d41398236a569af8ceb83f
BLAKE2b-256 4c85c6ef9005b0f02ce3bf7db2ecb05e2cfeb1431bbd94a8f2398a1f73cae4dd

See more details on using hashes here.

File details

Details for the file greenify-0.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.4.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 62f02c2e73b9ba71fabdc8b9e4bd2d0e524ac2aaed1cade4f7a41e11746eb618
MD5 0187dd5432c37d7ed144c7f9b4a084f5
BLAKE2b-256 3736244caaf44d4e5f626cbddf750022f25c5d51839cc72250ed6117b745f2d5

See more details on using hashes here.

File details

Details for the file greenify-0.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.4.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 40af75bf08eedf4890df38086860636e7d9da44f2c3b416631d4d86bb14f666b
MD5 c273f94914640cbeacececd0666363c7
BLAKE2b-256 350639756932bcda31c4f990563fd58875664616df613fea798226923a41e5c8

See more details on using hashes here.

File details

Details for the file greenify-0.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for greenify-0.4.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e88940ff703a7916929a5fcd84fed2760388db2e9b0d1fee8bbfab54affded84
MD5 5f260ccf02bef826732306abfaff293e
BLAKE2b-256 22501fcda91a29a083b0a78979625bac102ffd804ba13bd8084140a7d043092b

See more details on using hashes here.

Supported by

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