summaryrefslogtreecommitdiff
path: root/service/pixelated/bitmask_libraries
diff options
context:
space:
mode:
Diffstat (limited to 'service/pixelated/bitmask_libraries')
-rw-r--r--service/pixelated/bitmask_libraries/session.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py
index 9e908ce5..f28d9f59 100644
--- a/service/pixelated/bitmask_libraries/session.py
+++ b/service/pixelated/bitmask_libraries/session.py
@@ -53,12 +53,20 @@ class LeapSession(object):
self.fresh_account = False
self.incoming_mail_fetcher = None
self.account = None
+ self._has_been_synced = False
+ self._sem_intial_sync = defer.DeferredLock()
register(events.KEYMANAGER_FINISHED_KEY_GENERATION, self._set_fresh_account, uid=self.account_email())
@defer.inlineCallbacks
def initial_sync(self):
- yield self.sync()
- yield self.after_first_sync()
+ yield self._sem_intial_sync.acquire()
+ try:
+ if not self._has_been_synced:
+ yield self.sync()
+ yield self.after_first_sync()
+ self._has_been_synced = True
+ finally:
+ yield self._sem_intial_sync.release()
defer.returnValue(self)
@defer.inlineCallbacks