network: ensure we pass tasks to asyncio.wait
In Python < 3.11, when passing a coroutine to asyncio.wait, it would automatically be scheduled as a task. This isn't the case anymore with Python 3.11. Now passing coroutines to asyncio.wait fails with: TypeError: Passing coroutines is forbidden, use tasks explicitly. Let's ensure we schedule the coroutines as tasks before passing them on to asyncio.wait. Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
93ab4f911c
commit
0b7a4d16af
|
@ -169,7 +169,8 @@ class NetworkController(BaseNetworkController, SubiquityController):
|
|||
with context.child("wait_dhcp"):
|
||||
try:
|
||||
await asyncio.wait_for(
|
||||
asyncio.wait({e.wait() for e in dhcp_events}), 10
|
||||
asyncio.wait({asyncio.create_task(e.wait()) for e in dhcp_events}),
|
||||
10,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
|
|
|
@ -391,7 +391,9 @@ class BaseNetworkController(BaseController):
|
|||
return
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(asyncio.wait({e.wait() for e in dhcp_events}), 10)
|
||||
await asyncio.wait_for(
|
||||
asyncio.wait({asyncio.create_task(e.wait()) for e in dhcp_events}), 10
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue