Hi there,
After reading some of the source code, I figured out that this might be a
better minimal example for raising and receiving events in ryu:
-------
import gevent
from ryu.base import app_manager
from ryu.controller import event
from ryu.controller.handler import set_ev_cls
TEST_EVENT_EV_DISPATCHER = "test_event"
class TestEvent(event.EventBase):
def __init__(self, msg):
super(TestEvent, self).__init__()
self.msg = msg
class Test(app_manager.RyuApp):
_EVENTS = [TestEvent]
def __init__(self):
super(Test, self).__init__()
gevent.spawn_later(0, self._send_event_loop)
def _send_event_loop(self):
i = 0
while True:
self.send_event_to_observers(TestEvent(i))
i += 1
gevent.sleep(1)
@set_ev_cls(TestEvent, TEST_EVENT_EV_DISPATCHER)
def _recv_handler(self, ev):
print 'recv:', ev.msg
-------
Best regards,
Can Zhang
------------------------------------------------------------------------------
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