Open adrianmay opened 3 years ago
@adrianmay you were close. The examples in the main README may help you more.
async def x():
async with ts as tscm:
while True:
res = await tscm.recv()
print(res)
loop = asyncio.get_event_loop()
loop.run_until_complete(x())
You should probably update the documentation to this new system as it's rather confusing with the sudden library structure and having to refactor the codebase to fit this. I just understand why this was changed, when there was no apparent issue with the system.
I tried it with 'while true' too. Same result. Python's websocket docs don't have a 'while true'.
Also created a longer blog post with asyncio basics and examples
https://sammchardy.github.io/binance/2021/05/01/async-binance-basics.html
Got a 404 for that. You say "blog". Is that where people would look? Is the main doc being updated?
Thanks tho! Adrian.
On Tue, 4 May 2021 at 10:59, Sam McHardy @.***> wrote:
Also created a longer blog post with asyncio basics and examples
https://sammchardy.github.io/binance/2021/05/01/async-binance-basics.html
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sammchardy/python-binance/issues/805#issuecomment-831823328, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAARMR6TO7SZHSBCDTUQG3LTL7AO3ANCNFSM436APPOQ .
There are examples in the repo README https://github.com/sammchardy/python-binance
The websockets documentation had been updated https://github.com/sammchardy/python-binance/blob/master/docs/websockets.rst
The depth cache documentation had also been updated https://github.com/sammchardy/python-binance/blob/master/docs/depth_cache.rst
It seems these docs aren't updating on rtd.
The blog link is fixed now. https://sammchardy.github.io/binance/2021/05/01/async-binance-basics.html
Let me know what that's missing.
https://python-binance.readthedocs.io/ is now up to date
As an alternative to the new asyncio websocket class you can now use the ThreadedWebsocketManager class which abstracts away any asyncio requirements for you.
some examples here in the docs https://python-binance.readthedocs.io/en/latest/websockets.html
I Appreciate the updates and the timely responses. Thanks
The suggested code:
does not compile because the module is now called "streams" and because async can't be used outside of a functoin. Following python's async docs suggests:
but this prints only one trade, then times out and exits.
Please provide a working sample.