Issue type
Bug
How did you install PythonMonkey?
None
OS platform and distribution
Windows 11 x64
Python version (python --version)
3.13.0
PythonMonkey version (pip show pythonmonkey)
1.3.1
Bug Description
When awaiting a JavaScript async function from Python using asyncio.run(), PythonMonkey raises:
RuntimeError: PythonMonkey cannot find a running Python event-loop to make asynchronous calls.
However, a Python event loop is clearly running and can be retrieved with:
print(asyncio.get_running_loop())
which outputs:
<ProactorEventLoop running=True closed=False debug=False>
This suggests that PythonMonkey is unable to access the currently running event loop internally, even though one exists.
Standalone code to reproduce the issue
import asyncio
import pythonmonkey as pm
async def async_fn():
print(asyncio.get_running_loop())
await pm.eval("""
new Promise((resolve) => setTimeout((...args) => {
console.log(args);
resolve();
}, 1000, 42, "abc")
)
""")
await pm.eval("async (x) => await x")(asyncio.sleep(0.5))
asyncio.run(async_fn())
Relevant log output or backtrace
await pm.eval("""
~~~~~~~^^^^
new Promise((resolve) => setTimeout((...args) => {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
)
^
""")
^^^^
RuntimeError: PythonMonkey cannot find a running Python event-loop to make asynchronous calls
Additional info if applicable
What branch of PythonMonkey were you developing on? (If applicable)
No response
Issue type
Bug
How did you install PythonMonkey?
None
OS platform and distribution
Windows 11 x64
Python version (
python --version)3.13.0
PythonMonkey version (
pip show pythonmonkey)1.3.1
Bug Description
When awaiting a JavaScript async function from Python using
asyncio.run(), PythonMonkey raises:However, a Python event loop is clearly running and can be retrieved with:
print(asyncio.get_running_loop())
which outputs:
This suggests that PythonMonkey is unable to access the currently running event loop internally, even though one exists.
Standalone code to reproduce the issue
Relevant log output or backtrace
Additional info if applicable
What branch of PythonMonkey were you developing on? (If applicable)
No response