File: auto_monitor.py

package info (click to toggle)
pytango 10.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 10,216 kB
  • sloc: python: 28,206; cpp: 16,380; sql: 255; sh: 82; makefile: 43
file content (69 lines) | stat: -rw-r--r-- 1,661 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# SPDX-FileCopyrightText: All Contributors to the PyTango project
# SPDX-License-Identifier: LGPL-3.0-or-later

"""
This is an internal PyTango module.
"""

__all__ = ("auto_monitor_init",)

__docformat__ = "restructuredtext"

from tango._tango import AutoTangoMonitor, AutoTangoAllowThreads


def __AutoTangoMonitor__enter__(self):
    self._acquire()
    return self


def __AutoTangoMonitor__exit__(self, *args, **kwargs):
    self._release()


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):
            # code here is protected by the tango device monitor
            do something
    """


def __AutoTangoAllowThreads__enter__(self):
    return self


def __AutoTangoAllowThreads__exit__(self, *args, **kwargs):
    self._acquire()


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):
            # code here is not under the tango device monitor
            do something
    """


def auto_monitor_init(doc=True):
    __init_AutoTangoMonitor()
    __init_AutoTangoAllowThreads()
    if doc:
        __doc_AutoTangoMonitor()
        __doc_AutoTangoAllowThreads()