You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are a few opportunities to clean up the asyncio/threading behaviour.
If you are going to create a thread (e.g. for _run_socket), please provide a name parameter, e.g. name="pyTwitchAPI:_run_socket". This makes it easier debugging in larger systems.
EventSubWebsocket has its own Thread. This thread creates its own Event loop. I can't see how this is justified. It could be a task in the client's own event loop.
That would get rid of the callback_loop parameter complexity. (That tripped me up, and caused in my code bug it took ages to track down.) It will require EventSubBase.start() to become asynchronous, which is an API change.
There are several examples of busy loops - while loops with sleep() statements. Each can be replaced with the use of asyncio.Event - the busy waits are replaced with a wait on an Event. This is both more responsive and more efficient.
There are a few opportunities to clean up the asyncio/threading behaviour.
If you are going to create a thread (e.g. for _run_socket), please provide a
nameparameter, e.g.name="pyTwitchAPI:_run_socket". This makes it easier debugging in larger systems.EventSubWebsockethas its own Thread. This thread creates its own Event loop. I can't see how this is justified. It could be a task in the client's own event loop.That would get rid of the
callback_loopparameter complexity. (That tripped me up, and caused in my code bug it took ages to track down.) It will requireEventSubBase.start()to become asynchronous, which is an API change.This would address EventSub webhooks create own asyncio event loop and break on shutdown #350
There are several examples of busy loops - while loops with sleep() statements. Each can be replaced with the use of asyncio.Event - the busy waits are replaced with a wait on an Event. This is both more responsive and more efficient.