Only install the nginx hub if we're actually using nginx, because the import always works, so that wasn't a good test of whether to use it or not.

This commit is contained in:
donovan
2008-03-18 10:55:32 -07:00
parent ab7763795c
commit 5be20e0767
2 changed files with 6 additions and 8 deletions

View File

@@ -187,13 +187,6 @@ def exc_after(seconds, exc):
def get_default_hub(): def get_default_hub():
## TODO some sort of plugin system?
try:
import eventlet.hubs.nginx
return eventlet.hubs.nginx
except ImportError:
pass
try: try:
import eventlet.hubs.libevent import eventlet.hubs.libevent
return eventlet.hubs.libevent return eventlet.hubs.libevent

View File

@@ -4,6 +4,8 @@ import sys
from eventlet import api from eventlet import api
from eventlet import httpc from eventlet import httpc
from eventlet.hubs import nginx
def real_application(env, start_response): def real_application(env, start_response):
#result = httpc.get('http://127.0.0.1:8081/') #result = httpc.get('http://127.0.0.1:8081/')
@@ -23,6 +25,9 @@ def wrap_application(master, env, start_response):
def application(env, start_response): def application(env, start_response):
hub = api.get_hub() hub = api.get_hub()
if not isinstance(hub, nginx.Hub):
api.use_hub(nginx)
hub.poll_register = env['ngx.poll_register'] hub.poll_register = env['ngx.poll_register']
hub.poll_unregister = env['ngx.poll_unregister'] hub.poll_unregister = env['ngx.poll_unregister']
hub.sleep = env['ngx.sleep'] hub.sleep = env['ngx.sleep']