[pytango] 33/122: Fix Group.get_device and refactor __DeviceProxy__init__
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:18:15 UTC 2017
This is an automated email from the git hooks/post-receive script.
sbodomerle-guest pushed a commit to tag v9.2.1
in repository pytango.
commit 95ea2820474c50a7d7d7f820835339c40ae81c2b
Author: Vincent Michel <vincent.michel at maxlab.lu.se>
Date: Thu Sep 22 18:32:55 2016 +0200
Fix Group.get_device and refactor __DeviceProxy__init__
---
tango/device_proxy.py | 23 ++++++++++++++---------
tango/group.py | 5 +++--
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/tango/device_proxy.py b/tango/device_proxy.py
index 2540878..fb444a6 100644
--- a/tango/device_proxy.py
+++ b/tango/device_proxy.py
@@ -130,6 +130,15 @@ def __check_read_pipe(dev_pipe):
raise DevFailed(*dev_pipe.get_err_stack())
return dev_pipe
+def __init_device_proxy_internals(proxy):
+ if proxy.__dict__.get('_initialized', False):
+ return
+ executors = dict((key, None) for key in GreenMode.names)
+ proxy.__dict__['_green_mode'] = None
+ proxy.__dict__['_initialized'] = True
+ proxy.__dict__['_executors'] = executors
+ proxy.__dict__['_pending_unsubscribe'] = {}
+
def __DeviceProxy__get_cmd_cache(self):
try:
ret = self.__dict__['__cmd_cache']
@@ -152,15 +161,11 @@ def __DeviceProxy__get_pipe_cache(self):
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'] = ()
- executors[GreenMode.Futures] = kwargs.pop('executor', None)
- executors[GreenMode.Gevent] = kwargs.pop('threadpool', None)
- executors[GreenMode.Asyncio] = kwargs.pop('asyncio_executor', None)
+ __init_device_proxy_internals(self)
+ self._green_mode = kwargs.pop('green_mode', None)
+ self._executors[GreenMode.Futures] = kwargs.pop('executor', None)
+ self._executors[GreenMode.Gevent] = kwargs.pop('threadpool', None)
+ self._executors[GreenMode.Asyncio] = kwargs.pop('asyncio_executor', None)
return DeviceProxy.__init_orig__(self, *args, **kwargs)
def __DeviceProxy__get_green_mode(self):
diff --git a/tango/group.py b/tango/group.py
index 69e4639..687329f 100644
--- a/tango/group.py
+++ b/tango/group.py
@@ -17,10 +17,11 @@ __all__ = ["Group", "group_init"]
__docformat__ = "restructuredtext"
+import collections
from ._tango import __Group as _RealGroup, StdStringVector
from .utils import seq_2_StdStringVector, is_pure_str
from .utils import document_method as __document_method
-import collections
+from .device_proxy import __init_device_proxy_internals as init_device_proxy
def _apply_to(fn, key):
@@ -95,7 +96,7 @@ class Group:
def get_device(self, name_or_index):
proxy = self.__group.get_device(name_or_index)
- proxy.__init__(proxy)
+ init_device_proxy(proxy)
return proxy
def get_group(self, group_name):
--
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