• Stars
    star
    426
  • Rank 98,655 (Top 2 %)
  • Language
    C
  • License
    BSD 3-Clause "New...
  • Created about 12 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make blocking C library work with gevent

greenify

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.

More Repositories

1

DOUAudioStreamer

A Core Audio based streaming audio player for iOS and macOS
Objective-C
2,771
star
2

dpark

Python clone of Spark, a MapReduce alike framework in Python
Python
2,692
star
3

code

[DEPRECATED]Douban CODE
CSS
1,808
star
4

beansdb

Archived, see GoBeansDB instead.
C
871
star
5

douban-client

Python client library for Douban APIs (OAuth 2.0)
Python
743
star
6

rexxar-android

Mobile Hybrid Framework Rexxar Android Container
Java
667
star
7

rexxar-ios

Mobile Hybrid Framework Rexxar iOS Container
Objective-C
578
star
8

FRDIntent

A framework for handle the call between view controllers in iOS
Swift
493
star
9

gobeansdb

Distributed object storage server from Douban Inc.
Go
450
star
10

libmc

Fast and light-weight memcached client for C++ / #python / #golang #libmc
C++
442
star
11

ynm3k

UI Automation + YUItest driven acceptance tests that can be hooked into Jenkins
JavaScript
410
star
12

paracel

Distributed training framework with parameter server
C++
337
star
13

douban-objc-client

Objective-C client library for Douban APIs (OAuth 2.0)
Objective-C
254
star
14

beanseye

Proxy and monitor for beansdb in Go
Go
234
star
15

rexxar-web

Mobile Hybrid Framework Rexxar Web SDK
JavaScript
207
star
16

Kenshin

Kenshin: A time-series database alternative to Graphite Whisper with 40x improvement in IOPS
Python
205
star
17

tfmesos

Tensorflow in Docker on Mesos #tfmesos #tensorflow #mesos
Python
191
star
18

pymesos

A pure python implementation of Mesos scheduler and executor
Python
163
star
19

brownant

Brownant is a web data extracting framework.
Python
158
star
20

linguist

Language Savant, Python clone of github/linguist.
Python
153
star
21

graph-index

index of Graphite & Diamond
Python
129
star
22

CaoE

Kill all children processes when the parent dies
Python
97
star
23

douban-quixote

Douban's Quixote
Python
82
star
24

douban-utils

Douban's Utils
Python
59
star
25

python-libmemcached

DEPRECATED, use https://github.com/douban/libmc instead. python-libmemcached is a python extention for libmemcached
Python
57
star
26

PyCharlockHolmes

Character encoding detecting library for Python using ICU and libmagic.
Common Lisp
50
star
27

DOUSNSSharing

SNS OAuth 2 binding and sharing
Objective-C
47
star
28

ellen

Ellen is a wrapper of pygit2 and git command.
Python
41
star
29

Polymorph

Transform value of dictionary to property of Objective-C class, by using a `dynamic` like directive.
Objective-C
40
star
30

douban-sqlstore

Douban's MySQL lib.
Python
31
star
31

gpack

GIT Smart HTTP Server Rack Implementation, Python clone of https://github.com/schacon/grack
Python
30
star
32

douban-orz

The Missing Data Manager In Douban
Python
29
star
33

douban-mc

Douban's Memcached lib for python.
Python
27
star
34

helpdesk

Yet another helpdesk based on multiple providers
Python
22
star
35

sina

A GIT Smart HTTP Server WSGI Implementation.
Python
21
star
36

sa-tools-core

Handy tools for sysadmin.
Python
18
star
37

graphite-kenshin

A plugin for using graphite-web with the kenshin-based storage backend.
Python
16
star
38

charts

Helm charts from douban
Smarty
15
star
39

gobeansproxy

A proxy for GoBeansDB
Go
13
star
40

beansdbadmin

GoBeansDB Admin UI
Python
9
star
41

redarrow-rs

A command dispatcher to run executables remotely and safely.
Rust
6
star
42

MTURLProtocol

Multiple NSURLProtocol subclasses alternative solution.
Objective-C
4
star
43

python-libmagic

A wrapper for libmagic with static build.
Python
3
star
44

overlord

Overlord是哔哩哔哩基于Go语言编写的memcache和redis&cluster的代理及集群管理功能,致力于提供自动化高可用的缓存服务解决方案。
Go
3
star
45

qiniu-exporter

Go
2
star
46

aliyun-exporter

Go
2
star
47

pyquicklz

C
1
star
48

upyun-exporter

Go
1
star
49

sa-tools-go

go version for sa-tools
Go
1
star