Commit bb1ba3b2 authored by Colomban Wendling's avatar Colomban Wendling
Browse files

Mail thread: only report a task done when we actually handled a task

Don't account for a task in the `finally` handler as we actually got a
task only if we didn't receive an exception.  This cleans up the code
and possibly fixes it if we ever get any other exception than a
parent 8cf30efb
......@@ -46,12 +46,10 @@ class ThreadedSMTP(object):
server = None
while self._loop or not self._queue.empty():
task_eaten = True
args, kwargs = self._queue.get(timeout=timeout)
except queue.Empty:
server = self.__server_quit(server)
task_eaten = False # we didn't eat a task, just timeout
if len(args) or len(kwargs): # ignore empty items
......@@ -60,8 +58,6 @@ class ThreadedSMTP(object):
server.sendmail(*args, **kwargs)
except Exception as e:
logging.warning("Couldn't send email: %s" % str(e))
if task_eaten:
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