driftpy
driftpy copied to clipboard
Better handle or bubble up RPC errors
Account subscribers sometimes see unhelpful errors like this:
Traceback (most recent call last):
File "/example/drift_sdk.py", line 75, in <module>
asyncio.run(main())
File "/Users/ww/.pyenv/versions/3.10.11/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Users/ww/.pyenv/versions/3.10.11/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/example/drift_sdk.py", line 46, in main
await dc.subscribe()
File "/example/drift_client.py", line 167, in subscribe
await self.account_subscriber.subscribe()
File "/example/venv/lib/python3.10/site-packages/driftpy/accounts/ws/drift_client.py", line 71, in subscribe
) = await find_all_market_and_oracles(self.program, data_and_slots=True)
File "/example/venv/lib/python3.10/site-packages/driftpy/constants/config.py", line 142, in find_all_market_and_oracles
perp_slot = int(parsed_resp.result["context"]["slot"])
AttributeError: 'Error' object has no attribute 'result'
if we dig in and print resp
when it has no result, it's actually an RPC error:
Error(code=429, message='Too many requests for a specific RPC call, contact your app developer or [email protected].', data=None, id=1)