[pytango] 10/25: Fix auto tango monitor

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


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

sbodomerle-guest pushed a commit to tag v8.1.9
in repository pytango.

commit c4ea44e2c4119c755f50819bacac4c040bb973e4
Author: Vincent Michel <vincent.michel at maxlab.lu.se>
Date:   Fri Apr 22 16:31:02 2016 +0200

    Fix auto tango monitor
---
 src/boost/cpp/server/auto_monitor.cpp | 42 +++++++++++++++++++++++++++++------
 src/boost/python/auto_monitor.py      | 15 ++++++++-----
 2 files changed, 45 insertions(+), 12 deletions(-)

diff --git a/src/boost/cpp/server/auto_monitor.cpp b/src/boost/cpp/server/auto_monitor.cpp
index e1af8e3..676da31 100644
--- a/src/boost/cpp/server/auto_monitor.cpp
+++ b/src/boost/cpp/server/auto_monitor.cpp
@@ -18,21 +18,50 @@ namespace PyTango
 
 class AutoTangoMonitor
 {
-  Tango::AutoTangoMonitor           *mon;  
+  Tango::AutoTangoMonitor           *mon;
+  Tango::DeviceImpl                 *dev;
+  Tango::DeviceClass                *klass;
 
 public:
   AutoTangoMonitor(Tango::DeviceImpl *dev)
-  { mon = new Tango::AutoTangoMonitor(dev); }
+  {
+    this.dev = dev;
+  }
 
   AutoTangoMonitor(Tango::DeviceClass *klass)
-  { mon = new Tango::AutoTangoMonitor(klass); }
+  {
+    this.klass = klass;
+  }
+
+  void acquire()
+  {
+    if (mon == NULL)
+    {
+      if (dev != NULL)
+      {
+	AutoPythonAllowThreads no_gil;
+        mon = new Tango::AutoTangoMonitor(dev);
+      }
+      else if (klass != NULL)
+      {
+	AutoPythonAllowThreads no_gil;
+        mon = new Tango::AutoTangoMonitor(klass);
+      }
+    }
+  }
 
   void release()
   {
-    delete mon;
+    if (mon != NULL)
+    {
+      delete mon;
+    }
   }
 
-  ~AutoTangoMonitor() { release(); }
+  ~AutoTangoMonitor()
+  {
+    release();
+  }
 
 };
 
@@ -109,13 +138,12 @@ void export_auto_tango_monitor()
   bopy::class_<PyTango::AutoTangoMonitor, boost::noncopyable>(
     "AutoTangoMonitor", bopy::init<Tango::DeviceImpl*>())
     .def(bopy::init<Tango::DeviceClass*>())
+    .def("_acquire", &PyTango::AutoTangoMonitor::acquire)
     .def("_release", &PyTango::AutoTangoMonitor::release)
   ;
 
   bopy::class_<PyTango::AutoTangoAllowThreads, boost::noncopyable>(
     "AutoTangoAllowThreads", bopy::init<Tango::DeviceImpl*>())
-    
     .def("_acquire", &PyTango::AutoTangoAllowThreads::acquire);
   ;
 }
-
diff --git a/src/boost/python/auto_monitor.py b/src/boost/python/auto_monitor.py
index e4ad3f9..4b7c566 100644
--- a/src/boost/python/auto_monitor.py
+++ b/src/boost/python/auto_monitor.py
@@ -17,14 +17,14 @@ __all__ = ["auto_monitor_init"]
 
 __docformat__ = "restructuredtext"
 
-import copy
-
-from .utils import document_method as __document_method
 from ._PyTango import AutoTangoMonitor, AutoTangoAllowThreads
 
+
 def __AutoTangoMonitor__enter__(self):
+    self._acquire
     return self
 
+
 def __AutoTangoMonitor__exit__(self, *args, **kwargs):
     self._release()
 
@@ -33,9 +33,10 @@ def __init_AutoTangoMonitor():
     AutoTangoMonitor.__enter__ = __AutoTangoMonitor__enter__
     AutoTangoMonitor.__exit__ = __AutoTangoMonitor__exit__
 
+
 def __doc_AutoTangoMonitor():
     AutoTangoMonitor.__doc__ = """\
-    
+
     In a tango server, guard the tango monitor within a python context::
 
         with AutoTangoMonitor(dev):
@@ -43,9 +44,11 @@ def __doc_AutoTangoMonitor():
             do something
     """
 
+
 def __AutoTangoAllowThreads__enter__(self):
     return self
 
+
 def __AutoTangoAllowThreads__exit__(self, *args, **kwargs):
     self._acquire()
 
@@ -54,9 +57,10 @@ def __init_AutoTangoAllowThreads():
     AutoTangoAllowThreads.__enter__ = __AutoTangoAllowThreads__enter__
     AutoTangoAllowThreads.__exit__ = __AutoTangoAllowThreads__exit__
 
+
 def __doc_AutoTangoAllowThreads():
     AutoTangoAllowThreads.__doc__ = """\
-    
+
     In a tango server, free the tango monitor within a context:
 
         with AutoTangoAllowThreads(dev):
@@ -64,6 +68,7 @@ def __doc_AutoTangoAllowThreads():
             do something
     """
 
+
 def auto_monitor_init(doc=True):
     __init_AutoTangoMonitor()
     __init_AutoTangoAllowThreads()

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