uses to ryu.lib.hub instead.
Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
bin/ryu-manager | 11 +++++------
ryu/app/quantum_adapter.py | 4 ----
ryu/app/simple_vlan.py | 4 ++--
ryu/app/tunnel_port_updater.py | 10 +++++-----
ryu/app/wsgi.py | 4 ++--
ryu/base/app_manager.py | 10 ++++------
ryu/controller/controller.py | 15 +++++++--------
ryu/lib/ofctl_v1_0.py | 8 ++++----
ryu/lib/ovs/vsctl.py | 4 ++--
ryu/tests/integrated/test_of_config.py | 4 ++--
10 files changed, 33 insertions(+), 41 deletions(-)
diff --git a/bin/ryu-manager b/bin/ryu-manager
index 03b1b79..bab2b0c 100755
--- a/bin/ryu-manager
+++ b/bin/ryu-manager
@@ -16,9 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import gevent
-from gevent import monkey
-monkey.patch_all()
+from ryu.lib import hub
+hub.patch()
# TODO:
# Right now, we have our own patched copy of ovs python bindings
@@ -68,15 +67,15 @@ def main():
services = []
ctlr = controller.OpenFlowController()
- thr = gevent.spawn_later(0, ctlr)
+ thr = hub.spawn(ctlr)
services.append(thr)
webapp = wsgi.start_service(app_mgr)
if webapp:
- thr = gevent.spawn_later(0, webapp)
+ thr = hub.spawn(webapp)
services.append(thr)
- gevent.joinall(services)
+ hub.joinall(services)
app_mgr.close()
diff --git a/ryu/app/quantum_adapter.py b/ryu/app/quantum_adapter.py
index 8a7c0ff..ed9013c 100644
--- a/ryu/app/quantum_adapter.py
+++ b/ryu/app/quantum_adapter.py
@@ -36,10 +36,6 @@ from ryu.lib.ovs import bridge
from ryu.lib.quantum_ifaces import QuantumIfaces
-from gevent import monkey
-monkey.patch_all()
-
-
CONF = cfg.CONF
diff --git a/ryu/app/simple_vlan.py b/ryu/app/simple_vlan.py
index d92952b..bcbb17d 100644
--- a/ryu/app/simple_vlan.py
+++ b/ryu/app/simple_vlan.py
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import gevent
import logging
from ryu.app import (conf_switch_key,
@@ -27,6 +26,7 @@ from ryu.controller import (conf_switch,
tunnels)
import ryu.exception as ryu_exc
from ryu.lib import dpid as dpid_lib
+from ryu.lib import hub
from ryu.lib.ovs import bridge
from ryu.ofproto import nx_match
@@ -131,7 +131,7 @@ class SimpleVLAN(app_manager.RyuApp):
port_name = port.name.rstrip('\x00')
try:
ovs_br.set_db_attribute("Port", port_name, "tag", tunnel_key)
- except gevent.Timeout:
+ except hub.Timeout:
self.logger.error('timout')
return
diff --git a/ryu/app/tunnel_port_updater.py b/ryu/app/tunnel_port_updater.py
index 18ec079..5740d39 100644
--- a/ryu/app/tunnel_port_updater.py
+++ b/ryu/app/tunnel_port_updater.py
@@ -15,7 +15,6 @@
# limitations under the License.
import collections
-import gevent
from oslo.config import cfg
import logging
import netaddr
@@ -29,6 +28,7 @@ from ryu.controller import (conf_switch,
network,
tunnels)
from ryu.lib import dpid as dpid_lib
+from ryu.lib import hub
from ryu.lib.ovs import bridge as ovs_bridge
@@ -120,8 +120,8 @@ class TunnelDP(object):
self.conf_switch = conf_switch_
self.inited = False
- self.req_q = gevent.queue.Queue()
- self.thr = gevent.spawn_later(0, self._serve_loop)
+ self.req_q = hub.Queue()
+ self.thr = hub.spawn(self._serve_loop)
def _init(self):
self.ovs_bridge.init()
@@ -289,7 +289,7 @@ class TunnelDP(object):
if not self.inited:
try:
self._init()
- except gevent.timeout.Timeout:
+ except hub.Timeout:
self.logger.warn('_init timeouted')
req = None
@@ -315,7 +315,7 @@ class TunnelDP(object):
self._del_tunnel_port_ip(req.remote_ip)
else:
self.logger.error('unknown request %s', req)
- except gevent.timeout.Timeout:
+ except hub.Timeout:
# timeout. try again
self.logger.warn('timeout try again')
continue
diff --git a/ryu/app/wsgi.py b/ryu/app/wsgi.py
index f879b90..28bada0 100644
--- a/ryu/app/wsgi.py
+++ b/ryu/app/wsgi.py
@@ -17,7 +17,7 @@
from oslo.config import cfg
import webob.dec
-from gevent import pywsgi
+from ryu.lib import hub
from routes import Mapper
from routes.util import URLGenerator
@@ -80,7 +80,7 @@ class WSGIApplication(object):
return controller(req)
-class WSGIServer(pywsgi.WSGIServer):
+class WSGIServer(hub.WSGIServer):
def __init__(self, application, **config):
super(WSGIServer, self).__init__((CONF.wsapi_host, CONF.wsapi_port),
application, **config)
diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py
index a3abc85..1c2d283 100644
--- a/ryu/base/app_manager.py
+++ b/ryu/base/app_manager.py
@@ -17,13 +17,11 @@
import inspect
import itertools
import logging
-import gevent
-
-from gevent.queue import Queue
from ryu import utils
from ryu.controller.handler import register_instance
from ryu.controller.controller import Datapath
+from ryu.lib import hub
LOG = logging.getLogger('ryu.base.app_manager')
@@ -61,10 +59,10 @@ class RyuApp(object):
self.event_handlers = {}
self.observers = {}
self.threads = []
- self.events = Queue()
- self.replies = Queue()
+ self.events = hub.Queue()
+ self.replies = hub.Queue()
self.logger = logging.getLogger(self.name)
- self.threads.append(gevent.spawn(self._event_loop))
+ self.threads.append(hub.spawn(self._event_loop))
def register_handler(self, ev_cls, handler):
assert callable(handler)
diff --git a/ryu/controller/controller.py b/ryu/controller/controller.py
index c753f01..e88ff51 100644
--- a/ryu/controller/controller.py
+++ b/ryu/controller/controller.py
@@ -17,13 +17,12 @@
import contextlib
from oslo.config import cfg
import logging
-import gevent
+from ryu.lib import hub
+from ryu.lib.hub import StreamServer
import traceback
import random
import greenlet
import ssl
-from gevent.server import StreamServer
-from gevent.queue import Queue
import ryu.base.app_manager
@@ -124,7 +123,7 @@ class Datapath(object):
# The limit is arbitrary. We need to limit queue size to
# prevent it from eating memory up
- self.send_q = Queue(16)
+ self.send_q = hub.Queue(16)
self.set_version(max(self.supported_ofp_version))
self.xid = random.randint(0, self.ofproto.MAX_XID)
@@ -187,7 +186,7 @@ class Datapath(object):
count += 1
if count > 2048:
count = 0
- gevent.sleep(0)
+ hub.sleep(0)
@_deactivate
def _send_loop(self):
@@ -217,7 +216,7 @@ class Datapath(object):
self.send(msg.buf)
def serve(self):
- send_thr = gevent.spawn(self._send_loop)
+ send_thr = hub.spawn(self._send_loop)
# send hello message immediately
hello = self.ofproto_parser.OFPHello(self)
@@ -226,8 +225,8 @@ class Datapath(object):
try:
self._recv_loop()
finally:
- gevent.kill(send_thr)
- gevent.joinall([send_thr])
+ hub.kill(send_thr)
+ hub.joinall([send_thr])
#
# Utility methods for convenience
diff --git a/ryu/lib/ofctl_v1_0.py b/ryu/lib/ofctl_v1_0.py
index 1184b9b..e7d4007 100644
--- a/ryu/lib/ofctl_v1_0.py
+++ b/ryu/lib/ofctl_v1_0.py
@@ -16,9 +16,9 @@
import struct
import socket
import logging
-import gevent
from ryu.ofproto import ofproto_v1_0
+from ryu.lib import hub
from ryu.lib.mac import haddr_to_bin, haddr_to_str
@@ -173,13 +173,13 @@ def match_to_str(m):
def send_stats_request(dp, stats, waiters, msgs):
dp.set_xid(stats)
waiters_per_dp = waiters.setdefault(dp.id, {})
- lock = gevent.event.AsyncResult()
+ lock = hub.Event()
waiters_per_dp[stats.xid] = (lock, msgs)
dp.send_msg(stats)
try:
- lock.get(timeout=DEFAULT_TIMEOUT)
- except gevent.Timeout:
+ lock.wait(timeout=DEFAULT_TIMEOUT)
+ except hub.Timeout:
del waiters_per_dp[stats.xid]
diff --git a/ryu/lib/ovs/vsctl.py b/ryu/lib/ovs/vsctl.py
index 8cada74..420c48c 100644
--- a/ryu/lib/ovs/vsctl.py
+++ b/ryu/lib/ovs/vsctl.py
@@ -15,7 +15,6 @@
# limitations under the License.
-import gevent
import itertools
import logging
import operator
@@ -31,6 +30,7 @@ from ovs import (jsonrpc,
stream)
from ovs.db import idl
+from ryu.lib import hub
from ryu.lib.ovs import vswitch_idl
LOG = logging.getLogger(__name__) # use ovs.vlog?
@@ -1002,7 +1002,7 @@ class VSCtl(object):
if timeout_sec is None:
self._run_command(commands)
else:
- with gevent.Timeout(timeout_sec, exception):
+ with hub.Timeout(timeout_sec, exception):
self._run_command(commands)
# commands
diff --git a/ryu/tests/integrated/test_of_config.py
b/ryu/tests/integrated/test_of_config.py
index a8c4f9f..bf92af7 100644
--- a/ryu/tests/integrated/test_of_config.py
+++ b/ryu/tests/integrated/test_of_config.py
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import gevent
+from ryu.lib import hub
import traceback
import lxml.etree
@@ -121,7 +121,7 @@ class OFConfigClient(app_manager.RyuApp):
super(OFConfigClient, self).__init__(*args, **kwargs)
self.switch = capable_switch.OFCapableSwitch(
host=HOST, port=PORT, username=USERNAME, password=PASSWORD)
- gevent.spawn(self._do_of_config)
+ hub.spawn(self._do_of_config)
def _validate(self, tree):
xmlschema = _get_schema()
--
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