As a quick and dirty test I tried the following:
runPyInMain [pymain| import asyncio|]
foo ←
runPyInMain
[pyf|
async def foo():
print("running foo")
await asyncio.sleep(10)
print("ending foo")
return foo
|]
_ ←
forkIO $
runPy
[py_|
asyncio.run(foo_hs())
|]
_ ←
forkIO $
runPy
[py_|
asyncio.run(foo_hs())
|]
This causes the second thread to wait until the first thread to run its async function (as expected since it's waiting for the global lock). However, top-level async calls are not supported so I can't seem to be able to call async functions from multiple places without it blocking the global lock.
Is it possible run multiple async functions at the same time, but calling it from the Haskell side?
As a quick and dirty test I tried the following:
This causes the second thread to wait until the first thread to run its async function (as expected since it's waiting for the global lock). However, top-level
asynccalls are not supported so I can't seem to be able to call async functions from multiple places without it blocking the global lock.Is it possible run multiple async functions at the same time, but calling it from the Haskell side?