aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2020-09-25 11:00:09 -0300
committerJason Gunthorpe <jgg@nvidia.com>2020-09-25 11:00:09 -0300
commit83ee7cade37b23f608823f2ed59a1c315b7e9478 (patch)
tree4ee9cc339c4fd86d998bc94da05eb34331208aa4
parent13db1b030de3b885468d2473dd3d432000b21f31 (diff)
downloadcloud_mdir_sync-83ee7cade37b23f608823f2ed59a1c315b7e9478.tar.gz
cloud_mdir_sync-83ee7cade37b23f608823f2ed59a1c315b7e9478.tar.bz2
cloud_mdir_sync-83ee7cade37b23f608823f2ed59a1c315b7e9478.zip
util: Use a different algorithm for asyncio_complete()
The old version only worked on python > 3.7, this should work universally. Allow all the work in the gather list to finish naturally and just propogate any exceptions that might have been generated. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
-rw-r--r--cloud_mdir_sync/util.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/cloud_mdir_sync/util.py b/cloud_mdir_sync/util.py
index 836bf56..a35e5e4 100644
--- a/cloud_mdir_sync/util.py
+++ b/cloud_mdir_sync/util.py
@@ -75,9 +75,8 @@ async def asyncio_complete(*awo_list):
"""This is like asyncio.gather but it always ensures that the list of
awaitable objects is completed upon return. For instance if an exception
is thrown then all the awaitables are canceled"""
- g = asyncio.gather(*awo_list)
- try:
- return await g
- finally:
- g.cancel()
- await asyncio.gather(*awo_list, return_exceptions=True)
+ res = await asyncio.gather(*awo_list, return_exceptions=True)
+ for I in res:
+ if isinstance(I, Exception):
+ raise I
+ return res