From: Philippe Proulx Date: Wed, 24 Jul 2019 19:03:03 +0000 (-0400) Subject: bt2: move `_ListenerHandle` to `utils.py` X-Git-Tag: v2.0.0-rc1~412 X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=76f5df432a980121b58ec730f8b5142c6c19fc4b;p=babeltrace.git bt2: move `_ListenerHandle` to `utils.py` `_ListenerHandle` is not a name the package's user needs directly, so move it to the internal `utils.py` instead of having it available as `bt2._ListenerHandle`. Signed-off-by: Philippe Proulx Change-Id: I11b4476665b358d76379d73d8706dc6146d4b006 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1772 Tested-by: jenkins --- diff --git a/src/bindings/python/bt2/bt2/__init__.py.in b/src/bindings/python/bt2/bt2/__init__.py.in index 7859a22b..af5cd951 100644 --- a/src/bindings/python/bt2/bt2/__init__.py.in +++ b/src/bindings/python/bt2/bt2/__init__.py.in @@ -138,12 +138,6 @@ class _IncompleteUserClass(Exception): pass -class _ListenerHandle: - def __init__(self, listener_id, obj): - self._listener_id = listener_id - self._obj = obj - - def _init_and_register_exit(): import bt2.native_bt as _native_bt import atexit diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index 575747af..bed266f1 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -150,7 +150,7 @@ class Graph(object._SharedObject): if listener_ids is None: raise bt2._Error('cannot add listener to graph object') - return bt2._ListenerHandle(listener_ids, self) + return bt2.utils._ListenerHandle(listener_ids, self) def add_ports_connected_listener(self, listener): if not callable(listener): @@ -165,7 +165,7 @@ class Graph(object._SharedObject): if listener_ids is None: raise bt2._Error('cannot add listener to graph object') - return bt2._ListenerHandle(listener_ids, self) + return bt2.utils._ListenerHandle(listener_ids, self) def run(self): status = native_bt.graph_run(self._ptr) diff --git a/src/bindings/python/bt2/bt2/trace.py b/src/bindings/python/bt2/bt2/trace.py index a90b53ce..db8268db 100644 --- a/src/bindings/python/bt2/bt2/trace.py +++ b/src/bindings/python/bt2/bt2/trace.py @@ -190,4 +190,4 @@ class _Trace(object._SharedObject, collections.abc.Mapping): status, 'cannot add destruction listener to trace object' ) - return bt2._ListenerHandle(listener_id, self) + return bt2.utils._ListenerHandle(listener_id, self) diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index 5c4da5c7..d349ac0a 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -339,4 +339,4 @@ class _TraceClass(object._SharedObject, collections.abc.Mapping): status, 'cannot add destruction listener to trace class object' ) - return bt2._ListenerHandle(listener_id, self) + return bt2.utils._ListenerHandle(listener_id, self) diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index 3ad4f0b5..8db257ae 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -163,3 +163,9 @@ def _handle_func_status(status, msg=None): raise bt2.InvalidObject(msg) else: assert False + + +class _ListenerHandle: + def __init__(self, listener_id, obj): + self._listener_id = listener_id + self._obj = obj