Skip to content

Commit

Permalink
Merge pull request #137 from SoulTch/master
Browse files Browse the repository at this point in the history
asynq_to_async: handle edge case - empty list of tasks
  • Loading branch information
dkang-quora committed Mar 13, 2024
2 parents 5c98489 + e57a1e4 commit 169ee54
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asynq/asynq_to_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def is_asyncio_mode():
async def _gather(awaitables):
"""Gather awaitables, but wait all other awaitables to finish even if some of them fail."""

if len(awaitables) == 0:
return []

tasks = [asyncio.ensure_future(awaitable) for awaitable in awaitables]

# Wait for all tasks to finish, even if some of them fail.
Expand Down
6 changes: 6 additions & 0 deletions asynq/tests/test_asynq_to_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def g(x):

assert asyncio.run(g.asyncio(5)) == {"a": [1, 2], "b": (3, 4), "c": 5, "d": 200}

@asynq.asynq()
def empty():
return (yield [])

assert asyncio.run(empty.asyncio()) == []


def test_asyncio_exception():
call_count = 0
Expand Down

0 comments on commit 169ee54

Please sign in to comment.