The following code runs fine in my flask server, but when run by a celery worker it hangs.
from web3.auto.infura import w3
contract = w3.eth.contract(checksum_address, abi=abi)
decimals = contract.functions.decimals().call()
The DEBUG celery worker logs show
[2021-01-05 23:11:16,699: DEBUG/ForkPoolWorker-5] Making request. Method: eth_call
[2021-01-05 23:11:16,701: DEBUG/ForkPoolWorker-5] Making request WebSocket. URI: wss://mainnet.infura.io/ws/v3/<my project id>, Method: eth_call
I'm not very familiar with websockets, and after looking through the web3.py github issues, I noticed a few people mentioning that they use asyncio instead of celery for async operations with web3.py. I'm wondering if this is a celery configuration issue, a web3.py configuration issue, or maybe more simply, a poor choice of libraries.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…