From 986ff80c16efea0e32ff78012b2fd3c95b83e179 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Tue, 15 Jul 2014 16:24:49 -0300 Subject: Replace QThread with threading.Thread. --- src/leap/bitmask/backend/signaler_qt.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/leap/bitmask/backend/signaler_qt.py b/src/leap/bitmask/backend/signaler_qt.py index 4ec27a1e..433f18ed 100644 --- a/src/leap/bitmask/backend/signaler_qt.py +++ b/src/leap/bitmask/backend/signaler_qt.py @@ -33,7 +33,7 @@ import logging logger = logging.getLogger(__name__) -class SignalerQt(QtCore.QThread): +class SignalerQt(QtCore.QObject): """ Signaling server. Receives signals from the signaling client and emit Qt signals for the GUI. @@ -42,11 +42,24 @@ class SignalerQt(QtCore.QThread): BIND_ADDR = "tcp://127.0.0.1:%s" % PORT def __init__(self): - QtCore.QThread.__init__(self) + QtCore.QObject.__init__(self) + + # Note: we use a plain thread instead of a QThread since works better. + # The signaler was not responding on OSX if the worker loop was run in + # a QThread. + # Possibly, ZMQ was not getting cycles to do work because Qt not + # receiving focus or something. + self._worker_thread = threading.Thread(target=self._run) self._do_work = threading.Event() + + def start(self): + """ + Start the worker thread for the signaler server. + """ self._do_work.set() + self._worker_thread.start() - def run(self): + def _run(self): """ Start a loop to process the ZMQ requests from the signaler client. """ -- cgit v1.2.3