[pytango] 36/98: Fix cache problem when using DeviceProxy through an AttributeProxy

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


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

sbodomerle-guest pushed a commit to tag v9.2.0
in repository pytango.

commit 4f6a6a0db3aed711827881b8ec0255d0b6315101
Author: Jose Tiago Coutinho Macara <tiago.coutinho at esrf.fr>
Date:   Tue May 17 12:05:39 2016 +0200

    Fix cache problem when using DeviceProxy through an AttributeProxy
---
 src/boost/python/device_proxy.py | 50 +++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/boost/python/device_proxy.py b/src/boost/python/device_proxy.py
index a10f44a..92f5d11 100644
--- a/src/boost/python/device_proxy.py
+++ b/src/boost/python/device_proxy.py
@@ -130,13 +130,34 @@ def __check_read_pipe(dev_pipe):
         raise DevFailed(*dev_pipe.get_err_stack())
     return dev_pipe
 
+def __DeviceProxy__get_cmd_cache(self):
+    try:
+        ret = self.__dict__['__cmd_cache']
+    except KeyError:
+        self.__dict__['__cmd_cache'] = ret = {}
+    return ret
+
+def __DeviceProxy__get_attr_cache(self):
+    try:
+        ret = self.__dict__['__attr_cache']
+    except KeyError:
+        self.__dict__['__attr_cache'] = ret = ()
+    return ret
+
+def __DeviceProxy__get_pipe_cache(self):
+    try:
+        ret = self.__dict__['__pipe_cache']
+    except KeyError:
+        self.__dict__['__pipe_cache'] = ret = ()
+    return ret
+
 def __DeviceProxy__init__(self, *args, **kwargs):
     self.__dict__['_green_mode'] = kwargs.pop('green_mode', None)
     self.__dict__['_executors'] = executors = {}
     self.__dict__['_pending_unsubscribe'] = {}
-    self.__dict__['__cmd_cache'] = {}
-    self.__dict__['__attr_cache'] = ()
-    self.__dict__['__pipe_cache'] = ()
+#    self.__dict__['__cmd_cache'] = {}
+#    self.__dict__['__attr_cache'] = ()
+#    self.__dict__['__pipe_cache'] = ()
     executors[GreenMode.Futures] = kwargs.pop('executor', None)
     executors[GreenMode.Gevent] = kwargs.pop('threadpool', None)
     executors[GreenMode.Asyncio] = kwargs.pop('asyncio_executor', None)
@@ -207,14 +228,14 @@ def __DeviceProxy__getattr(self, name):
 
     name_l = name.lower()
 
-    cmd_info = self.__cmd_cache.get(name_l)
+    cmd_info = self.__get_cmd_cache().get(name_l)
     if cmd_info:
         return __get_command_func(self, cmd_info, name)
 
-    if name_l in self.__attr_cache:
+    if name_l in self.__get_attr_cache():
         return self.read_attribute(name).value
 
-    if name_l in self.__pipe_cache:
+    if name_l in self.__get_pipe_cache():
         return self.read_pipe(name)
 
     try:
@@ -222,7 +243,7 @@ def __DeviceProxy__getattr(self, name):
     except:
         pass
 
-    cmd_info = self.__cmd_cache.get(name_l)
+    cmd_info = self.__get_cmd_cache().get(name_l)
     if cmd_info:
         return __get_command_func(self, cmd_info, name)
 
@@ -231,7 +252,7 @@ def __DeviceProxy__getattr(self, name):
     except:
         pass
 
-    if name_l in self.__attr_cache:
+    if name_l in self.__get_attr_cache():
         return self.read_attribute(name).value
 
     try:
@@ -239,7 +260,7 @@ def __DeviceProxy__getattr(self, name):
     except Exception as e:
         pass
 
-    if name_l in self.__pipe_cache:
+    if name_l in self.__get_pipe_cache():
         return self.read_pipe(name)
 
     raise AttributeError(name)
@@ -247,10 +268,10 @@ def __DeviceProxy__getattr(self, name):
 def __DeviceProxy__setattr(self, name, value):
     name_l = name.lower()
 
-    if name_l in self.__attr_cache:
+    if name_l in self.__get_attr_cache():
         return self.write_attribute(name, value)
 
-    if name_l in self.__pipe_cache:
+    if name_l in self.__get_pipe_cache():
         return self.write_pipe(name, value)
 
     try:
@@ -258,7 +279,7 @@ def __DeviceProxy__setattr(self, name, value):
     except:
         pass
 
-    if name_l in self.__attr_cache:
+    if name_l in self.__get_attr_cache():
         return self.write_attribute(name, value)
 
     try:
@@ -266,7 +287,7 @@ def __DeviceProxy__setattr(self, name, value):
     except:
         pass
 
-    if name_l in self.__pipe_cache:
+    if name_l in self.__get_pipe_cache():
         return self.write_pipe(name, value)
 
     return super(DeviceProxy, self).__setattr__(name, value)
@@ -1280,6 +1301,9 @@ def __init_DeviceProxy():
 
     DeviceProxy._getAttributeNames = __DeviceProxy__getAttributeNames
 
+    DeviceProxy.__get_cmd_cache = __DeviceProxy__get_cmd_cache
+    DeviceProxy.__get_attr_cache = __DeviceProxy__get_attr_cache
+    DeviceProxy.__get_pipe_cache = __DeviceProxy__get_pipe_cache
     DeviceProxy.__refresh_cmd_cache = __DeviceProxy__refresh_cmd_cache
     DeviceProxy.__refresh_attr_cache = __DeviceProxy__refresh_attr_cache
     DeviceProxy.__refresh_pipe_cache = __DeviceProxy__refresh_pipe_cache

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