diff options
author | Kali Kaneko <kali@leap.se> | 2014-02-11 01:41:05 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2014-02-17 11:39:48 -0400 |
commit | 630798ef91504b5d01ba7f673532a5875ba8c9a8 (patch) | |
tree | 356a17e8e9002fdeeefede48d08a9deea37425f8 /mail | |
parent | 2b09d4d09bf9f30840c0cb77f3c41fc6dfb63096 (diff) |
make the condition optional
Diffstat (limited to 'mail')
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index 726049c3..6041961f 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -129,7 +129,7 @@ class LeapIMAPFactory(ServerFactory): imapProtocol.factory = self return imapProtocol - def doStop(self, cv): + def doStop(self, cv=None): """ Stops imap service (fetcher, factory and port). @@ -142,21 +142,23 @@ class LeapIMAPFactory(ServerFactory): """ ServerFactory.doStop(self) - def _stop_imap_cb(): - logger.debug('Stopping in memory store.') - self._memstore.stop_and_flush() - while not self._memstore.producer.is_queue_empty(): - logger.debug('Waiting for queue to be empty.') - # TODO use a gatherResults over the new/dirty deferred list, - # as in memorystore's expunge() method. - time.sleep(1) - # notify that service has stopped - logger.debug('Notifying that service has stopped.') - cv.acquire() - cv.notify() - cv.release() - - return threads.deferToThread(_stop_imap_cb) + if cv is not None: + def _stop_imap_cb(): + logger.debug('Stopping in memory store.') + self._memstore.stop_and_flush() + while not self._memstore.producer.is_queue_empty(): + logger.debug('Waiting for queue to be empty.') + # TODO use a gatherResults over the new/dirty + # deferred list, + # as in memorystore's expunge() method. + time.sleep(1) + # notify that service has stopped + logger.debug('Notifying that service has stopped.') + cv.acquire() + cv.notify() + cv.release() + + return threads.deferToThread(_stop_imap_cb) def run_service(*args, **kwargs): |