pyodide / pyodide/pyodide

Asyncio run_until_complete() returns a Task instead of the result of the coroutine

Open
#3,932 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
14.8k
Forks
1k
Avg merge
20h 29m
Merged PRs (30d)
19

Description

## Question

When running an async coroutine until completion with asyncio.run_until_complete(), I would expect to get the data returned by the coroutine but I get a Task object which is pending instead

### To Reproduce
```
import asyncio

async def my_coroutine():
return "Hello, world!"

# loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
task = loop.create_task(my_coroutine())
result = loop.run_until_complete(task)
print(result)
```
### Expected behavior

The result returned is something like:
```
:3> cb=[WebLoop._decrement_in_progress()]>
```
whereas I would have expected:
```
Hello, world!
```
(which is the case with Python 3.11)

### Environment

- Pyodide Version: 0.23.0
- Browser version: Chrome 114.0.5735.110
- Any other relevant information:

### Additional context

Thanks for any help in clarifying why I can't get the result of the coroutine here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.