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?

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()

------------------------------------------------------------------------------
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

Reply via email to