On Thu, 10 Apr 2014 09:50:03 +0900 (JST) [email protected] (YAMAMOTO Takashi) wrote:
>> On Wed, 26 Mar 2014 13:04:15 +0900 >> YAMAMOTO Takashi <[email protected]> wrote: >> >>> this method undos register_handler. >>> >>> Signed-off-by: YAMAMOTO Takashi <[email protected]> >>> --- >>> ryu/base/app_manager.py | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py >>> index 291c0ad..ec42f97 100644 >>> --- a/ryu/base/app_manager.py >>> +++ b/ryu/base/app_manager.py >>> @@ -158,6 +158,10 @@ class RyuApp(object): >>> self.event_handlers.setdefault(ev_cls, []) >>> self.event_handlers[ev_cls].append(handler) >>> >>> + def unregister_handler(self, ev_cls, handler): >>> + assert callable(handler) >>> + self.event_handlers[ev_cls].remove(handler) >> >> Nice to delete a key if its list is empty? > > sure, it's nicer. Applied. >From d3f8f4eb4cfa3a89164e4ef723d1cc80eb07a68c Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori <[email protected]> Date: Thu, 10 Apr 2014 09:51:26 +0900 Subject: [PATCH] RyuApp: delete a key without handlers when unregistering a handler Signed-off-by: FUJITA Tomonori <[email protected]> --- ryu/base/app_manager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ryu/base/app_manager.py b/ryu/base/app_manager.py index bdba1ec..971918c 100644 --- a/ryu/base/app_manager.py +++ b/ryu/base/app_manager.py @@ -169,6 +169,8 @@ class RyuApp(object): def unregister_handler(self, ev_cls, handler): assert callable(handler) self.event_handlers[ev_cls].remove(handler) + if not event_handlers[ev_cls]: + del event_handlers[ev_cls] def register_observer(self, ev_cls, name, states=None): states = states or set() -- 1.8.5.2 (Apple Git-48) ------------------------------------------------------------------------------ Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test & Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
