diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2015-07-08 16:15:09 -0300 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-07-20 19:14:36 -0400 |
commit | 0d9c53c4ec182c6bf3452506351258b61bb1f739 (patch) | |
tree | 3f3edeb10a65b4862fdc0fa53b787d1bc47b3654 | |
parent | d6abcc95e70d8c76dc4998766cbca5c444bd8915 (diff) |
[bug] prevent logbook subscriber to fail
Fix:
If the logbook controller is not started the stop call will fail.
Trying to start it twice fails.
-rw-r--r-- | changes/bug-7273_logbook-subscriber-start | 2 | ||||
-rw-r--r-- | src/leap/bitmask/logs/utils.py | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/changes/bug-7273_logbook-subscriber-start b/changes/bug-7273_logbook-subscriber-start new file mode 100644 index 00000000..976d2f35 --- /dev/null +++ b/changes/bug-7273_logbook-subscriber-start @@ -0,0 +1,2 @@ +- Closes bug #7273 - ZMQError: address already in use - logbook subscriber already started. +- Closes bug - logbook subscriber stop fails if not started. diff --git a/src/leap/bitmask/logs/utils.py b/src/leap/bitmask/logs/utils.py index f0e820b2..683fb542 100644 --- a/src/leap/bitmask/logs/utils.py +++ b/src/leap/bitmask/logs/utils.py @@ -188,15 +188,17 @@ class QtLogHandler(logbook.Handler, logbook.StringFormatterHandlerMixin): class _LogController(object): def __init__(self): self._qt_handler = QtLogHandler(format_string=LOG_FORMAT) + self._logbook_controller = None self.new_log = self._qt_handler.qt.new_log def start_logbook_subscriber(self): """ Run in the background the log receiver. """ - subscriber = ZeroMQSubscriber('tcp://127.0.0.1:5000', multi=True) - self._logbook_controller = subscriber.dispatch_in_background( - self._qt_handler) + if self._logbook_controller is None: + subscriber = ZeroMQSubscriber('tcp://127.0.0.1:5000', multi=True) + self._logbook_controller = subscriber.dispatch_in_background( + self._qt_handler) def stop_logbook_subscriber(self): """ @@ -205,8 +207,10 @@ class _LogController(object): This allows us to re-create the subscriber when we reopen this window without getting an error at trying to connect twice to the zmq port. """ - self._logbook_controller.stop() - self._logbook_controller.subscriber.close() + if self._logbook_controller is not None: + self._logbook_controller.stop() + self._logbook_controller.subscriber.close() + self._logbook_controller = None def get_logs(self): return self._qt_handler.logs |