diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2020-02-07 11:52:43 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2020-02-07 12:11:03 -0400 |
commit | d1877aaf5a791204dd7222f50fc33b5f802c7e94 (patch) | |
tree | 8c6db52a7656bc99da9e196913de95953771fbc5 /cloud_mdir_sync/office365.py | |
parent | f44a42f276e01514a1e4bf3028639aaea58138c6 (diff) | |
download | cloud_mdir_sync-d1877aaf5a791204dd7222f50fc33b5f802c7e94.tar.gz cloud_mdir_sync-d1877aaf5a791204dd7222f50fc33b5f802c7e94.tar.bz2 cloud_mdir_sync-d1877aaf5a791204dd7222f50fc33b5f802c7e94.zip |
Don't leave asyncio tasks running unexpectedly
All cases where gather is called intend that the tasks will complete
successfully or all cancel at the first error. Add a little wrapper to
achieve this.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'cloud_mdir_sync/office365.py')
-rw-r--r-- | cloud_mdir_sync/office365.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cloud_mdir_sync/office365.py b/cloud_mdir_sync/office365.py index f96ef29..9cfaf0d 100644 --- a/cloud_mdir_sync/office365.py +++ b/cloud_mdir_sync/office365.py @@ -13,6 +13,7 @@ import aiohttp import requests from . import config, mailbox, messages, util +from .util import asyncio_complete def _retry_protect(func): @@ -488,7 +489,7 @@ class O365Mailbox(mailbox.Mailbox): asyncio.create_task(self._fetch_message(msg))) msgs.append(msg) - await asyncio.gather(*todo) + await asyncio_complete(*todo) res = {} for msg in msgs: @@ -652,8 +653,8 @@ class O365Mailbox(mailbox.Mailbox): body={"destinationId": "deleteditems"})) del self.messages[ch] - await asyncio.gather(*todo_flags) + await asyncio_complete(*todo_flags) # Delete must be temporally after move as move will change the mailbox # id. - await asyncio.gather(*todo_del) + await asyncio_complete(*todo_del) self.last_merge_len = len(todo_flags) + len(todo_del) |