fix #1720 -- don't wait for the daemon eventhread to terminate but count on it to eventually die

This commit is contained in:
holger krekel
2020-07-15 16:53:30 +02:00
parent f461e2a2fd
commit a27b379ce0
3 changed files with 17 additions and 3 deletions

View File

@@ -139,6 +139,7 @@ class EventThread(threading.Thread):
self.account = account
super(EventThread, self).__init__(name="events")
self.setDaemon(True)
self._marked_for_shutdown = False
self.start()
@contextmanager
@@ -147,6 +148,9 @@ class EventThread(threading.Thread):
yield
self.account.log(message + " FINISHED")
def mark_shutdown(self):
self._marked_for_shutdown = True
def wait(self):
if self == threading.current_thread():
# we are in the callback thread and thus cannot
@@ -164,10 +168,12 @@ class EventThread(threading.Thread):
lib.dc_get_event_emitter(self.account._dc_context),
lib.dc_event_emitter_unref,
)
while 1:
while not self._marked_for_shutdown:
event = lib.dc_get_next_event(event_emitter)
if event == ffi.NULL:
break
if self._marked_for_shutdown:
break
evt = lib.dc_event_get_id(event)
data1 = lib.dc_event_get_data1_int(event)
# the following code relates to the deltachat/_build.py's helper