instead, allow to specify the type of hub by RYU_HUB_TYPE environment variable. make the default eventlet.
Signed-off-by: YAMAMOTO Takashi <[email protected]> --- ryu/lib/hub.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ryu/lib/hub.py b/ryu/lib/hub.py index 0c376c7..7ff1db1 100644 --- a/ryu/lib/hub.py +++ b/ryu/lib/hub.py @@ -16,23 +16,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -# use gevent if available. otherwise use eventlet. +import os -try: + +# we don't bother to use cfg.py because monkey patch needs to be +# called very early. instead, we use an environment variable to +# select the type of hub. +HUB_TYPE = os.getenv('RYU_HUB_TYPE', 'eventlet') + +if HUB_TYPE == 'gevent': import gevent import gevent.monkey import gevent.pywsgi import gevent.queue - GEVENT = True -except: - import eventlet - import eventlet.wsgi - import eventlet.timeout - import eventlet.queue - import ssl - GEVENT = False -if GEVENT: spawn = gevent.spawn patch = gevent.monkey.patch_all sleep = gevent.sleep @@ -52,7 +49,14 @@ if GEVENT: def wait(self, timeout=None): self._ev.wait(timeout) -else: +elif HUB_TYPE == 'eventlet': + import eventlet + import eventlet.event + import eventlet.queue + import eventlet.timeout + import eventlet.wsgi + import ssl + spawn = eventlet.spawn patch = eventlet.monkey_patch sleep = eventlet.sleep -- 1.8.0.1 ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
