Skip to content

Conversation

@nagy
Copy link
Contributor

@nagy nagy commented May 20, 2025

This is my attempt to make the API more pythonic.

For each subscription on the WebSocket we are now creating a asyncio.Queue.

https://docs.python.org/3/library/asyncio-queue.html

This way, we do not have to count the number of received responses, but can let asyncio.gather handle all that calculation for us as you can see in details.py. The usage of asyncio.Queue allows further simplification in other files, which are not in this PR. recv2 creates a loop that is feeding these queues with newly arrived messages and is therefore a asyncio.Task that needs to be started at the beginning. This is currently done in details_loop but I would rather collect that at a more centralized place.

https://docs.python.org/3/library/asyncio-task.html#asyncio.Task

The intention is not to introduce these new 2-suffixed function, but to show how the other functions could look like.
If the overall idea looks good to you, then I can change all the other functions as well to follow this scheme and undraft this PR.

For each WebSocket subscription `Queues` are now being filled.
A collection task is being started at the beginning of a command to
fill these queues.
@ExploracuriousAlex
Copy link
Contributor

That looks nice. This could also make the Timeline module cleaner and better readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants