[pytango] 394/483: Fix #659
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:15:04 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 fdf6ed960474ddcd167d38f6413cdd3e10363873
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Thu Jun 19 13:24:56 2014 +0000
Fix #659
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@25919 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
doc/revision.rst | 3 +++
src/boost/python/device_proxy.py | 23 ++++++++++++++++++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/doc/revision.rst b/doc/revision.rst
index 11d0076..a4f422d 100644
--- a/doc/revision.rst
+++ b/doc/revision.rst
@@ -91,7 +91,10 @@ Version history
| version | Changes |
+==========+=======================================================================================================================================================================+
| 8.1.3 | Features: |
+| | |
| | Bug fixes: |
+| | |
+| | - `659: segmentation fault when unsubscribing from events <https://sourceforge.net/p/tango-cs/bugs/659/>`_ |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 8.1.2 | Features: |
| | |
diff --git a/src/boost/python/device_proxy.py b/src/boost/python/device_proxy.py
index 19223f8..ad1abc7 100644
--- a/src/boost/python/device_proxy.py
+++ b/src/boost/python/device_proxy.py
@@ -19,6 +19,7 @@ __all__ = ["device_proxy_init", "get_device_proxy"]
__docformat__ = "restructuredtext"
+import time
import threading
import collections
@@ -33,6 +34,7 @@ from .utils import seq_2_DbData, DbData_2_dict
from .utils import document_method as __document_method
from .green import result, submit, green, get_green_mode
+_UNSUBSCRIBE_LIFETIME = 60
def get_device_proxy(*args, **kwargs):
"""get_device_proxy(self, dev_name, green_mode=None, wait=True, timeout=True) -> DeviceProxy
@@ -121,6 +123,7 @@ def __check_read_attribute(dev_attr):
def __DeviceProxy__init__(self, *args, **kwargs):
self.__dict__['_green_mode'] = kwargs.pop('green_mode', None)
self.__dict__['_executors'] = executors = {}
+ self.__dict__['_pending_unsubscribe'] = {}
executors[GreenMode.Futures] = kwargs.pop('executor', None)
executors[GreenMode.Gevent] = kwargs.pop('threadpool', None)
return DeviceProxy.__init_orig__(self, *args, **kwargs)
@@ -863,11 +866,25 @@ def __DeviceProxy__unsubscribe_event(self, event_id):
Throws : EventSystemFailed
"""
+ events_del = set()
+ timestamp = time.time()
+ se = self.__get_event_map()
+
with self.__get_event_map_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))
+ # first delete event callbacks that have expire
+ for evt_id, (_, expire_time) in self._pending_unsubscribe.items():
+ if expire_time <= timestamp:
+ events_del.add(evt_id)
+ for evt_id in events_del:
+ del self._pending_unsubscribe[evt_id]
+
+ # unsubscribe and put the callback in the pending unsubscribe callbacks
+ try:
+ evt_info = se[event_id]
+ except KeyError:
+ raise KeyError("This device proxy does not own this subscription " + str(event_id))
del se[event_id]
+ self._pending_unsubscribe[event_id] = evt_info[0], timestamp + _UNSUBSCRIBE_LIFETIME
self.__unsubscribe_event(event_id)
def __DeviceProxy__unsubscribe_event_all(self):
--
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