/greenreactor

A reactor which makes twisted run on gevent

Primary LanguagePythonApache License 2.0Apache-2.0

Greenreactor

A reactor which make twisted compatc with gevent

Motivation

Originally I wrote code for Scrapy. I want to combine gevent in Scrapy, so I created this greenreactor.

Installation

pip install greenreactor

Usage

# Usually we need monkey patch, simply patch all things or patch part of them if you understand what you are doing.
# Guideline: http://www.gevent.org/api/gevent.monkey.html
import gevent.monkey
# Disable some patch properly, for example: DISABLE THREAD PATCH ---- gevent.monkey.patch_all(thread=False)
gevent.monkey.patch_all()


# Install greenreactor
import greenreactor
greenreactor.install()

from twisted.internet import reactor
reactor.run()

Thats all! Now you can use any gevent api such as spawn, spawn_later, etc.