Skip to content

Commit

Permalink
async_helpers: only pass a single positional argument to create_task
Browse files Browse the repository at this point in the history
asyncio.create_task only accepts one positional argument and passing
more than one results in the following exception:

TypeError: create_task() takes 1 positional argument but 2 were given

Therefore, it does not make sense for run_bg_task to forward *args to
it.

Signed-off-by: Olivier Gayot <[email protected]>
  • Loading branch information
ogayot committed Jun 19, 2024
1 parent 86bce5c commit 30b54da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subiquitycore/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def schedule_task(coro, propagate_errors=True):
background_tasks = set()


def run_bg_task(coro, *args, **kwargs) -> None:
def run_bg_task(coro, **kwargs) -> None:
"""Run a background task in a fire-and-forget style."""
task = asyncio.create_task(coro, *args, **kwargs)
task = asyncio.create_task(coro, **kwargs)
background_tasks.add(task)
task.add_done_callback(background_tasks.discard)

Expand Down

0 comments on commit 30b54da

Please sign in to comment.