Commit 68679d8b authored by Matias Guijarro's avatar Matias Guijarro

workaround the Tango file descriptors problem (see tango-controls/pytango/issues/324)

Added 'ApiUtil' to bliss.common.tango
parent 1721aea0
......@@ -4,7 +4,14 @@ from bliss.common.proxy import Proxy
from enum import IntEnum
import functools
__all__ = ["AttrQuality", "EventType", "DevState", "AttributeProxy", "DeviceProxy"]
__all__ = [
"AttrQuality",
"EventType",
"DevState",
"AttributeProxy",
"DeviceProxy",
"ApiUtil",
]
class AttrQuality(IntEnum):
......@@ -68,8 +75,25 @@ def Database(*args, **kwargs):
)
class _ApiUtil:
def __getattribute__(self, attr):
raise RuntimeError(
"Tango is not imported. Hint: is tango Python module installed ?"
)
ApiUtil = _ApiUtil()
try:
from tango import AttrQuality, EventType, DevState, DevFailed, Database, DevSource
from tango import (
AttrQuality,
EventType,
DevState,
DevFailed,
Database,
DevSource,
ApiUtil,
)
from tango.gevent import (
DeviceProxy as _DeviceProxy,
AttributeProxy as _AttributeProxy,
......@@ -84,6 +108,7 @@ except ImportError:
DevFailed,
Database,
DevSource,
ApiUtil,
)
from PyTango.gevent import (
DeviceProxy as _DeviceProxy,
......
......@@ -149,7 +149,7 @@ bliss % more setup.cfg
[tool:pytest]
addopts = -v --ignore=tests/images --ignore=tests/test_configuration --ignore=tests/controllers_hw
usefixtures = clean_louie clean_gevent clean_globals
usefixtures = clean_louie clean_gevent clean_globals clean_tango
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning
......
[tool:pytest]
addopts = -v --ignore=tests/images --ignore=tests/test_configuration --ignore=tests/controllers_hw --ignore=tests/emulators
usefixtures = clean_louie clean_gevent clean_globals
usefixtures = clean_louie clean_gevent clean_globals clean_tango
filterwarnings =
ignore::DeprecationWarning
ignore::PendingDeprecationWarning
......
......@@ -15,7 +15,6 @@ import gevent
import subprocess
import signal
import logging
import pytest
import redis
......@@ -29,7 +28,7 @@ from bliss.controllers.lima.roi import Roi
from bliss.controllers.wago.wago import ModulesConfig
from bliss.controllers import simulation_diode
from bliss.common import plot
from bliss.common.tango import DeviceProxy, DevFailed
from bliss.common.tango import DeviceProxy, DevFailed, ApiUtil
from bliss import logging_startup
from random import randint
......@@ -132,6 +131,16 @@ def clean_globals():
simulation_diode.DEFAULT_INTEGRATING_CONTROLLER = None
@pytest.fixture
def clean_tango():
# close file descriptors left open by Tango (see tango-controls/pytango/issues/324)
try:
ApiUtil.cleanup()
except RuntimeError:
# no Tango ?
pass
@pytest.fixture(scope="session")
def config_app_port(ports):
yield ports.cfgapp_port
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment