question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Python 3.11 TypeError: Passing coroutines is forbidden, use tasks explicitly.

See original GitHub issue

The 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:open
  • Created 9 months ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cretzcommented, Dec 23, 2022

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.

1reaction
cretzcommented, Dec 23, 2022

Though to wait for something until timeout, wait_for is the better approach

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found