[pytango] 46/483: better event subscription/unsubscription

Sandor Bodo-Merle sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

sbodomerle-guest pushed a commit to annotated tag bliss_8.10
in repository pytango.

commit 59de4c623e91e4461fcf58a2a35766452b16d595
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date:   Tue Oct 18 17:27:40 2011 +0000

    better event subscription/unsubscription
    
    git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@18115 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
 PyTango/device_proxy.py | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/PyTango/device_proxy.py b/PyTango/device_proxy.py
index 52aac69..92ee2c9 100644
--- a/PyTango/device_proxy.py
+++ b/PyTango/device_proxy.py
@@ -733,9 +733,7 @@ def __DeviceProxy__subscribe_event ( self, attr_name, event_type, cb_or_queuesiz
 
     event_id = self.__subscribe_event(attr_name, event_type, cb, filters, stateless, extract_as)
 
-    l = self.__get_event_map_lock()
-    l.acquire()
-    try:
+    with self.__get_event_map_lock() as lock:
         se = self.__get_event_map()
         evt_data = se.get(event_id)
         if evt_data is not None:
@@ -745,8 +743,6 @@ def __DeviceProxy__subscribe_event ( self, attr_name, event_type, cb_or_queuesiz
                    (self, attr_name, event_type, event_id, evt_data[2], evt_data[1])
             Except.throw_exception("Py_InternalError", desc, "DeviceProxy.subscribe_event")
         se[event_id] = (cb, event_type, attr_name)
-    finally:
-        l.release()
     return event_id
 
 def __DeviceProxy__unsubscribe_event(self, event_id):
@@ -765,26 +761,18 @@ def __DeviceProxy__unsubscribe_event(self, event_id):
 
         Throws     : EventSystemFailed
     """
-    l = self.__get_event_map_lock()
-    l.acquire()
-    try:
+    with self.__get_event_map_lock() as lock:
         se = self.__get_event_map()
         if event_id not in se:
             raise IndexError("This device proxy does not own this subscription " + str(event_id))
         del se[event_id]
-    finally:
-        l.release()
     self.__unsubscribe_event(event_id)
 
 def __DeviceProxy__unsubscribe_event_all(self):
-    l = self.__get_event_map_lock()
-    l.acquire()
-    try:
+    with self.__get_event_map_lock() as lock:
         se = self.__get_event_map()
         event_ids = se.keys()
         se.clear()
-    finally:
-        l.release()
     for event_id in event_ids:
         self.__unsubscribe_event(event_id)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pytango.git



More information about the debian-science-commits mailing list