-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
When multiple concurrent asyncio tasks share a single AsyncSubstrateInterface instance and make RPC calls simultaneously, it triggers a RecursionError in the _wait_with_activity_timeout method.
Reproduction
import asyncio
from async_substrate_interface import AsyncSubstrateInterface
async def concurrent_task(substrate):
"""Simulate a task making RPC calls on a shared substrate instance."""
for _ in range(10):
await substrate.get_block_number(None)
async def main():
substrate = AsyncSubstrateInterface(
url="wss://test.finney.opentensor.ai:443",
)
try:
# Run 5 concurrent tasks sharing the same substrate instance
await asyncio.gather(
concurrent_task(substrate),
concurrent_task(substrate),
concurrent_task(substrate),
concurrent_task(substrate),
concurrent_task(substrate),
)
print("✅ No error detected")
finally:
await substrate.close()
if __name__ == "__main__":
asyncio.run(main())Expected Behavior
Multiple concurrent tasks should be able to share a single AsyncSubstrateInterface instance without triggering recursion errors.
Actual Behavior
RecursionError: maximum recursion depth exceeded
File "async_substrate_interface/async_substrate.py", line 668, in _wait_with_activity_timeout
return await self._wait_with_activity_timeout(main_task, timeout)
[Previous line repeated 982 more times]
Environment
- Python: 3.12.11
- async-substrate-interface: >=1.5.11
Metadata
Metadata
Assignees
Labels
No labels