Skip to content

Commit

Permalink
modify parameters passed to asyncio.wait to avoid deprecation warning. (
Browse files Browse the repository at this point in the history
#160)

Remove asyncio.wait deprecation warning by only passing tasks to it.

In the master scheduler _do_task method, a coroutine is passed to
asyncio.wait. This is deprecated behaviour. I noticed this while working
on #153:

```
File "/workspace/tickit/src/tickit/core/management/schedulers/master.py", line 102, in _do_tick
    which, _ = await asyncio.wait(
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 377, in wait
    warnings.warn("The explicit passing of coroutine objects to "
DeprecationWarning: The explicit passing of coroutine objects to asyncio.wait() is deprecated since Python 3.8, and scheduled for removal in Python 3.11.
```
  • Loading branch information
rosesyrett authored Jul 18, 2023
1 parent 4a0a678 commit 7b4a00f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tickit/core/management/schedulers/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ async def _do_tick(self):
assert when is not None
self.new_wakeup.clear()

current: asyncio.Future = asyncio.sleep(self.sleep_time(when))
new = asyncio.create_task(self.new_wakeup.wait())
current = asyncio.create_task(asyncio.sleep(self.sleep_time(when)))
which, _ = await asyncio.wait(
[current, new], return_when=asyncio.tasks.FIRST_COMPLETED
)
Expand Down

0 comments on commit 7b4a00f

Please sign in to comment.