[Bug] Python 3.11 TypeError: Passing coroutines is forbidden, use tasks explicitly.
See original GitHub issueThe following lines of code run without issue in Python 3.10, but throw in 3.11:
await asyncio.wait(
[asyncio.sleep((snooze_until - now).total_seconds()), self._is_reopened.wait()],
return_when=asyncio.FIRST_COMPLETED,
)
(this is similar to an example in the readme, so it seems idiomatic)
The error I get in 3.11 is TypeError: Passing coroutines is forbidden, use tasks explicitly.
Encountered on the python:3.11-slim
Docker image, initially using temporalio=0.1b3
, reproduced on 0.1b4
I think the relevant Python docs are https://docs.python.org/3/library/asyncio-task.html#waiting-primitives
Passing coroutine objects to wait() directly is forbidden
Not sure if I’d class it as a bug, as the change in Python appears to be deliberate, but it means the canonical way to solve this in Temporal might now be different?
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Passing coroutines is forbidden, use tasks explicitly ... - GitHub
"TypeError: Passing coroutines is forbidden, use tasks explicitly." #10743 ... Also note in the traceback, you are using Python 3.11.
Read more >Coroutines and Tasks — Python 3.11.1 documentation
Changed in version 3.10: Removed the loop parameter. Changed in version 3.11: Passing coroutine objects to wait() directly is forbidden. Run awaitable objects ......
Read more >Bug#1026551: aioftp: FTBFS: TypeError: Passing coroutines ...
... File "/usr/lib/python3.11/asyncio/tasks.py", line 415, in wait > raise TypeError("Passing coroutines is forbidden, use tasks explicitly.
Read more >Alternative to asyncio.wait? - python - Stack Overflow
I don't want a warning in console every time I launch my application. Edit: I don't want to just hide the error, that's...
Read more >python-websockets(1) - Arch manual pages
#!/usr/bin/env python import asyncio import websockets async def ... play() raises RuntimeError because the move is illegal, send an event of type "error"; ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That wait_for example looks fine. Yes you can leave this open for me to update the README.
The best practice is to use asyncio in Temporal like you would outside of Temporal.
Though to wait for something until timeout, wait_for is the better approach