Skip to content

asyncio clean-up #354

Description

@Julian-O

There are a few opportunities to clean up the asyncio/threading behaviour.

  1. 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.

  2. 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.

    This would address EventSub webhooks create own asyncio event loop and break on shutdown #350

  3. 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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions