polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
241 stars 115 forks source link

substrate websocket getting blocked at subscription_handler #352

Closed Jessie-1 closed 1 year ago

Jessie-1 commented 1 year ago

unable to subscribe more due to blocking.

arjanz commented 1 year ago

The library is intended for a sync environment, but if you aim to subscribe to multiple storage keys at once you can have a look at the subscribe_storage() function, see docs:

https://polkascan.github.io/py-substrate-interface/usage/subscriptions/#subscribe-to-multiple-storage-keys

Otherwise you can resort to work with threads, be sure to use a separate instance of SubstrateInterface per thread because otherwise it wouldn't be threadsafe. See examples mentioned in:

https://github.com/polkascan/py-substrate-interface/issues/206#issue-1188620072

https://github.com/polkascan/py-substrate-interface/issues/82#issuecomment-810957617