summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/leap/common/events/__init__.py19
-rw-r--r--src/leap/common/events/client.py13
-rw-r--r--src/leap/common/events/txclient.py11
3 files changed, 22 insertions, 21 deletions
diff --git a/src/leap/common/events/__init__.py b/src/leap/common/events/__init__.py
index 18d0ac8..f9ad5fa 100644
--- a/src/leap/common/events/__init__.py
+++ b/src/leap/common/events/__init__.py
@@ -41,6 +41,7 @@ import argparse
from leap.common.events import client
from leap.common.events import txclient
from leap.common.events import server
+from leap.common.events import flags
from leap.common.events.flags import set_events_enabled
from leap.common.events import catalog
@@ -78,11 +79,13 @@ def register(event, callback, uid=None, replace=False):
:raises CallbackAlreadyRegistered: when there's already a callback
identified by the given uid and replace is False.
"""
- return client.register(event, callback, uid, replace)
+ if flags.EVENTS_ENABLED:
+ return client.register(event, callback, uid, replace)
def register_async(event, callback, uid=None, replace=False):
- return txclient.register(event, callback, uid, replace)
+ if flags.EVENTS_ENABLED:
+ return txclient.register(event, callback, uid, replace)
def unregister(event, uid=None):
@@ -97,11 +100,13 @@ def unregister(event, uid=None):
:param uid: The callback uid.
:type uid: str
"""
- return client.unregister(event, uid)
+ if flags.EVENTS_ENABLED:
+ return client.unregister(event, uid)
def unregister_async(event, uid=None):
- return txclient.unregister(event, uid)
+ if flags.EVENTS_ENABLED:
+ return txclient.unregister(event, uid)
def emit(event, *content):
@@ -113,11 +118,13 @@ def emit(event, *content):
:param content: The content of the event.
:type content: list
"""
- return client.emit(event, *content)
+ if flags.EVENTS_ENABLED:
+ return client.emit(event, *content)
def emit_async(event, *content):
- return txclient.emit(event, *content)
+ if flags.EVENTS_ENABLED:
+ return txclient.emit(event, *content)
if __name__ == "__main__":
diff --git a/src/leap/common/events/client.py b/src/leap/common/events/client.py
index e085f5b..e38e9d3 100644
--- a/src/leap/common/events/client.py
+++ b/src/leap/common/events/client.py
@@ -465,7 +465,7 @@ class EventsClientThread(threading.Thread, EventsClient):
Make sure the events client thread is started.
"""
with self._lock:
- if flags.EVENTS_ENABLED and not self.is_alive():
+ if not self.is_alive():
self.daemon = True
self.start()
self._initialized.wait()
@@ -508,9 +508,8 @@ def register(event, callback, uid=None, replace=False):
:raises CallbackAlreadyRegisteredError: when there's already a callback
identified by the given uid and replace is False.
"""
- if flags.EVENTS_ENABLED:
- return EventsClientThread.instance().register(
- event, callback, uid=uid, replace=replace)
+ return EventsClientThread.instance().register(
+ event, callback, uid=uid, replace=replace)
def unregister(event, uid=None):
@@ -525,8 +524,7 @@ def unregister(event, uid=None):
:param uid: The callback uid.
:type uid: str
"""
- if flags.EVENTS_ENABLED:
- return EventsClientThread.instance().unregister(event, uid=uid)
+ return EventsClientThread.instance().unregister(event, uid=uid)
def emit(event, *content):
@@ -538,8 +536,7 @@ def emit(event, *content):
:param content: The content of the event.
:type content: list
"""
- if flags.EVENTS_ENABLED:
- return EventsClientThread.instance().emit(event, *content)
+ return EventsClientThread.instance().emit(event, *content)
def instance():
diff --git a/src/leap/common/events/txclient.py b/src/leap/common/events/txclient.py
index be4b3ef..f3c183e 100644
--- a/src/leap/common/events/txclient.py
+++ b/src/leap/common/events/txclient.py
@@ -146,9 +146,8 @@ def register(event, callback, uid=None, replace=False):
:raises CallbackAlreadyRegisteredError: when there's already a callback
identified by the given uid and replace is False.
"""
- if flags.EVENTS_ENABLED:
- return EventsTxClient.instance().register(
- event, callback, uid=uid, replace=replace)
+ return EventsTxClient.instance().register(
+ event, callback, uid=uid, replace=replace)
def unregister(event, uid=None):
@@ -163,8 +162,7 @@ def unregister(event, uid=None):
:param uid: The callback uid.
:type uid: str
"""
- if flags.EVENTS_ENABLED:
- return EventsTxClient.instance().unregister(event, uid=uid)
+ return EventsTxClient.instance().unregister(event, uid=uid)
def emit(event, *content):
@@ -176,8 +174,7 @@ def emit(event, *content):
:param content: The content of the event.
:type content: list
"""
- if flags.EVENTS_ENABLED:
- return EventsTxClient.instance().emit(event, *content)
+ return EventsTxClient.instance().emit(event, *content)
def shutdown():