daemonize helper threads so that sys.exit() during startup works

with daemonize set to False, the app hangs waiting on the helper threads
This commit is contained in:
Damien Elmes 2019-04-29 14:36:44 +10:00
parent 90dd0efed4
commit 9fb5a3257c
2 changed files with 3 additions and 0 deletions

View file

@ -197,6 +197,7 @@ class MPVBase:
"""Start up the communication threads. """Start up the communication threads.
""" """
self._thread = threading.Thread(target=self._reader) self._thread = threading.Thread(target=self._reader)
self._thread.daemon = True
self._thread.start() self._thread.start()
def _stop_thread(self): def _stop_thread(self):
@ -450,6 +451,7 @@ class MPV(MPVBase):
""" """
super()._start_thread() super()._start_thread()
self._event_thread = threading.Thread(target=self._event_reader) self._event_thread = threading.Thread(target=self._event_reader)
self._event_thread.daemon = True
self._event_thread.start() self._event_thread.start()
def _stop_thread(self): def _stop_thread(self):

View file

@ -47,6 +47,7 @@ class MediaServer(threading.Thread):
_port = None _port = None
_ready = threading.Event() _ready = threading.Event()
daemon = True
def __init__(self, mw, *args, **kwargs): def __init__(self, mw, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)