From 10330b390de4dfaf72853ecb4454bf4142415add Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 27 Sep 2016 22:04:41 -0300 Subject: [bug] stop syncing after logout (#8479) --- src/leap/bitmask/mail/incoming/service.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/leap/bitmask/mail/incoming') diff --git a/src/leap/bitmask/mail/incoming/service.py b/src/leap/bitmask/mail/incoming/service.py index b4cdfcf..86c3055 100644 --- a/src/leap/bitmask/mail/incoming/service.py +++ b/src/leap/bitmask/mail/incoming/service.py @@ -31,7 +31,6 @@ from urlparse import urlparse from twisted.application.service import Service from twisted.application.service import IService from twisted.logger import Logger -from twisted.python.failure import Failure from twisted.internet import defer, reactor from twisted.internet.task import LoopingCall from twisted.internet.task import deferLater @@ -183,27 +182,23 @@ class IncomingMail(Service): def startService(self): """ - Starts a loop to fetch mail. - - :returns: A Deferred whose callback will be invoked with - the LoopingCall instance when loop.stop is called, or - whose errback will be invoked when the function raises an - exception or returned a deferred that has its errback - invoked. + Start a loop to fetch mail. """ + if self.running: + return + Service.startService(self) if self._loop is None: self._loop = LoopingCall(self.fetch) - stop_deferred = self._loop.start(self._check_period) - return stop_deferred - else: - logger.warning("Tried to start an already running fetching loop.") - return defer.fail(Failure('Already running loop.')) + self._loop.start(self._check_period) def stopService(self): """ Stops the loop that fetches mail. """ + if not self.running: + return + if self._loop and self._loop.running is True: self._loop.stop() self._loop = None -- cgit v1.2.3