Closed bryaan closed 1 year ago
asyncio.run(coro)
? https://docs.python.org/3/library/asyncio-runner.html#asyncio.run
It works in python but when calling it from julia im getting an error.
import asyncio
async def create_filter_coro(web3, fromBlock, topics):
eventFilter = await web3.eth.filter({
"fromBlock": fromBlock,
"topics": topics
})
return eventFilter
def create_filter_async(web3, fromBlock, topics):
return asyncio.run(create_filter_coro(web3, fromBlock, topics))
web3 = web3.AsyncWeb3(web3.AsyncHTTPProvider(jsonRpcUrl))
eventFilter = utils.create_filter_async(web3, 17418534, ["xxx"])
┌ Error: 2023-06-05 23:44:06 Unexpected PyException:
│ exception =
│ Python: TypeError: object function can't be used in 'await' expression
│ Python stacktrace:
│ [1] construct_middleware
│ @ web3.middleware ~/Library/Caches/pypoetry/virtualenvs/cryptopy-5siZoxZ4-py3.10/lib/python3.10/site-packages/web3/middleware/__init__.py:130
│ [2] async_combine_middlewares
│ @ web3.middleware ~/Library/Caches/pypoetry/virtualenvs/cryptopy-5siZoxZ4-py3.10/lib/python3.10/site-packages/web3/middleware/__init__.py:119
Again in python alone the code works. So it must be something with this lib and async functions or types.
The call stack points to this line: https://github.com/ethereum/web3.py/blame/c99135587614c4f95275ea27dd3227f45ac23c73/web3/middleware/__init__.py#L130
Can you provide a full MWE of how to get to the error, and include the full error output too please.
I'm going to leave this as is for now since this library doesn't really support threading.
How do you await a coroutine generated by python in julia using PythonCall.jl?
This would seem to work for a future. But what about coroutines?