Commit 2a65dc4f authored by Colomban Wendling's avatar Colomban Wendling

Properly make the mail thread a daemon thread and properly quit it

A stupid typo lead for the mail thread not to be a daemon thread, thus
preventing Python from quitting before that thread quits by itself.

So properly make it a daemon thread, and as it would now actually get
interrupted abruptly, register an atexit handler to cleanly quit it.
parent 3c87d5ae
...@@ -8,6 +8,7 @@ from time import strftime ...@@ -8,6 +8,7 @@ from time import strftime
import email.charset import email.charset
from threading import Thread from threading import Thread
import queue import queue
import atexit
# Switch to quoted-printable so that we don't get something completely # Switch to quoted-printable so that we don't get something completely
# unreadable for non-ASCII chars if we have to look at raw email # unreadable for non-ASCII chars if we have to look at raw email
...@@ -21,8 +22,10 @@ class ThreadedSMTP(object): ...@@ -21,8 +22,10 @@ class ThreadedSMTP(object):
self._queue = queue.Queue() self._queue = queue.Queue()
self._loop = True self._loop = True
self._thread = Thread(target=self.__loop) self._thread = Thread(target=self.__loop)
self._thread.deamon = True self._thread.daemon = True
self._thread.start() self._thread.start()
# properly clean up on quit
atexit.register(self.quit)
def quit(self): def quit(self):
if self._loop: if self._loop:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment