Skip to content

Commit

Permalink
Merge pull request #181 from davfsa/task/fix-linting
Browse files Browse the repository at this point in the history
Fix mypy error
  • Loading branch information
Nekokatt authored Sep 14, 2020
2 parents 6066d91 + 5602b3e commit 884a32b
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions hikari/utilities/aio.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ async def first_completed(
"""
fs = list(map(asyncio.ensure_future, aws))
iterator = asyncio.as_completed(fs, timeout=timeout)
cancelled = False
timed_out = False
try:
await next(iterator)
except asyncio.CancelledError:
cancelled = True
raise asyncio.CancelledError("first_completed gatherer cancelled") from None
except asyncio.TimeoutError:
timed_out = True
raise asyncio.TimeoutError("first_completed gatherer timed out") from None
finally:
for f in fs:
if not f.done() and not f.cancelled():
Expand All @@ -137,11 +135,6 @@ async def first_completed(
except asyncio.CancelledError:
pass

if cancelled:
raise asyncio.CancelledError("first_completed gatherer cancelled")
if timed_out:
raise asyncio.TimeoutError("first_completed gatherer timed out")


async def all_of(
*aws: typing.Awaitable[T_co],
Expand All @@ -167,14 +160,13 @@ async def all_of(
"""
fs = list(map(asyncio.ensure_future, aws))
gatherer = asyncio.gather(*fs)
cancelled = False
timed_out = False

try:
return await asyncio.wait_for(gatherer, timeout=timeout)
except asyncio.TimeoutError:
timed_out = True
raise asyncio.TimeoutError("all_of gatherer timed out") from None
except asyncio.CancelledError:
cancelled = True
raise asyncio.CancelledError("all_of gatherer cancelled") from None
finally:
for f in fs:
if not f.done() and not f.cancelled():
Expand All @@ -189,8 +181,3 @@ async def all_of(
await gatherer
except asyncio.CancelledError:
pass

if cancelled:
raise asyncio.CancelledError("all_of gatherer cancelled")
if timed_out:
raise asyncio.TimeoutError("all_of gatherer timed out")

0 comments on commit 884a32b

Please sign in to comment.