[pytango] 289/483: fix problem with import when gevent is not installed
Sandor Bodo-Merle
sbodomerle-guest at moszumanska.debian.org
Thu Sep 28 19:14:51 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 e36e715d8c1f12f339717c990d720b4e38f038fb
Author: tiagocoutinho <tiagocoutinho at 4e9c00fd-8f2e-0410-aa12-93ce3db5e235>
Date: Fri Nov 8 08:31:08 2013 +0000
fix problem with import when gevent is not installed
git-svn-id: http://svn.code.sf.net/p/tango-cs/code/bindings/PyTango/trunk@24145 4e9c00fd-8f2e-0410-aa12-93ce3db5e235
---
src/boost/python/device_proxy.py | 11 +++++------
src/boost/python/tango_futures.py | 14 ++++----------
src/boost/python/tango_gevent.py | 5 +++--
src/boost/python/tango_green.py | 4 ++--
4 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/boost/python/device_proxy.py b/src/boost/python/device_proxy.py
index 167a37b..af441b8 100644
--- a/src/boost/python/device_proxy.py
+++ b/src/boost/python/device_proxy.py
@@ -135,7 +135,7 @@ def __check_read_attribute(dev_attr):
return dev_attr
def __DeviceProxy__init__(self, *args, **kwargs):
- self.__dict__['_green_mode'] = kwargs.pop('green_mode', get_green_mode())
+ self.__dict__['_green_mode'] = kwargs.pop('green_mode', None)
self.__dict__['_executors'] = executors = {}
executors[GreenMode.Futures] = kwargs.pop('executor', None)
executors[GreenMode.Gevent] = kwargs.pop('threadpool', None)
@@ -143,8 +143,6 @@ def __DeviceProxy__init__(self, *args, **kwargs):
def __DeviceProxy__get_green_mode(self):
"""Returns the green mode in use by this DeviceProxy.
- It returns None if it is using the global PyTango green mode
- (see :func:`PyTango.utils.get_green_mode`).
:returns: the green mode in use by this DeviceProxy.
:rtype: GreenMode
@@ -155,7 +153,10 @@ def __DeviceProxy__get_green_mode(self):
New in PyTango 8.1.0
"""
- return self._green_mode
+ gm = self._green_mode
+ if gm is None:
+ gm = get_green_mode()
+ return gm
def __DeviceProxy__set_green_mode(self, green_mode=None):
"""Sets the green mode to be used by this DeviceProxy
@@ -167,8 +168,6 @@ def __DeviceProxy__set_green_mode(self, green_mode=None):
New in PyTango 8.1.0
"""
- if green_mode is None:
- green_mode = get_green_mode()
self._green_mode = green_mode
diff --git a/src/boost/python/tango_futures.py b/src/boost/python/tango_futures.py
index 7afbfd8..00a87e2 100644
--- a/src/boost/python/tango_futures.py
+++ b/src/boost/python/tango_futures.py
@@ -23,20 +23,11 @@
__all__ = ["uses_future", "get_global_executor", "submit", "spawn"]
-__use_future = None
__global_executor = None
+
MAX_WORKERS = 8
MODE = 'thread'
-def uses_future():
- global __use_future
- if __use_future is None:
- try:
- import concurrent.futures
- __use_future = True
- except ImportError:
- __use_future = False
- return __use_future
def __get_executor_class():
import concurrent.futures
@@ -47,6 +38,7 @@ def __get_executor_class():
ret = concurrent.futures.ProcessPoolExecutor
return ret
+
def get_global_executor():
global __global_executor
if __global_executor is None:
@@ -55,7 +47,9 @@ def get_global_executor():
__global_executor = klass(max_workers=MAX_WORKERS)
return __global_executor
+
def submit(fn, *args, **kwargs):
return get_global_executor().submit(fn, *args, **kwargs)
+
spawn = submit
diff --git a/src/boost/python/tango_gevent.py b/src/boost/python/tango_gevent.py
index dec4958..46d2f9e 100644
--- a/src/boost/python/tango_gevent.py
+++ b/src/boost/python/tango_gevent.py
@@ -25,15 +25,16 @@ from __future__ import absolute_import
__all__ = ["get_global_threadpool", "get_global_executor", "submit", "spawn"]
-import gevent
-
def get_global_threadpool():
+ import gevent
return gevent.get_hub().threadpool
+
def spawn(fn, *args, **kwargs):
return get_global_threadpool().spawn(fn, *args, **kwargs)
get_global_executor = get_global_threadpool
+
submit = spawn
diff --git a/src/boost/python/tango_green.py b/src/boost/python/tango_green.py
index 29e7909..6edb6cb 100644
--- a/src/boost/python/tango_green.py
+++ b/src/boost/python/tango_green.py
@@ -94,8 +94,8 @@ def submitable(obj, green_mode=None):
:returns: green_mode, submit callable"""
# determine the efective green_mode
if green_mode is None:
- if hasattr(obj, "_green_mode"):
- green_mode = obj._green_mode
+ if hasattr(obj, "get_green_mode"):
+ green_mode = obj.get_green_mode()
else:
green_mode = get_green_mode()
--
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