diff options
author | drebs <drebs@riseup.net> | 2016-09-27 22:04:41 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2016-10-03 12:01:29 -0300 |
commit | 10330b390de4dfaf72853ecb4454bf4142415add (patch) | |
tree | 59c8079d983f7442897c39c14e51ac7272d79baa /src/leap/bitmask/mail/incoming | |
parent | 9c4bf6adf42f0f9553ae11f24ffeb6f7cf39f374 (diff) |
[bug] stop syncing after logout (#8479)
Diffstat (limited to 'src/leap/bitmask/mail/incoming')
-rw-r--r-- | src/leap/bitmask/mail/incoming/service.py | 21 |
1 files changed, 8 insertions, 13 deletions
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 |