diff --git a/cloud_mdir_sync/main.py b/cloud_mdir_sync/main.py index db33af8..4b98992 100644 --- a/cloud_mdir_sync/main.py +++ b/cloud_mdir_sync/main.py @@ -134,7 +134,9 @@ def main(): pyinotify.AsyncioNotifier(wm, cfg.loop) cfg.watch_manager = wm cfg.msgdb = msgdb - cfg.loop.run_until_complete(synchronize_mail(cfg)) + cfg.loop.run_until_complete(asyncio.gather(synchronize_mail(cfg))) + + cfg.logger.exception("Main loop finished tidying up") cfg.loop.run_until_complete(cfg.loop.shutdown_asyncgens()) cfg.loop.close() diff --git a/cloud_mdir_sync/office365.py b/cloud_mdir_sync/office365.py index 7425cad..722f029 100644 --- a/cloud_mdir_sync/office365.py +++ b/cloud_mdir_sync/office365.py @@ -44,6 +44,8 @@ def _retry_protect(func): continue if e.code == 429: # Too Many Requests delay = int(e.headers.get("Retry-After", 10)) + if delay < 10: + delay = 10 self.cfg.logger.error( f"Graph returns {e} Too Many Requests, {e.headers.get('Rate-Limit-Reason')}, delaying {delay}" ) @@ -791,9 +793,9 @@ class O365Mailbox(mailbox.Mailbox): self._update_msg_flags(todo_flags, cmsg, old_cmsg.flags, lmsg) # Debugging that the message really is to be deleted - if cmsg is not None and lmsg is None: - assert os.stat(os.path.join(self.msgdb.hashes_dir, - ch)).st_nlink == 1 + #if cmsg is not None and lmsg is None: + # assert os.stat(os.path.join(self.msgdb.hashes_dir, + # ch)).st_nlink == 1 if cmsg is not None and (lmsg is None or lmsg.flags & messages.Message.FLAG_DELETED):