Skip to content

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

@tt2468

Description

@tt2468

When shutting down an EventSubWebhook eventsub class with await stop(), it attempts to call things running in a different event loop. This is because for some reason the webhook operates in a dedicated event loop on a different thread. Additionally, it uses asyncio.set_event_loop, which further modifies the user's asyncio state. This does not appear to be documented anywhere.

The only way to avoid a RuntimeError being thrown when calling await stop() in my case is to perform the following:
asyncio.run_coroutine_threadsafe(eventsub.stop(), eventsub._EventSubWebhook__hook_loop).result(timeout = 5)

Unfortunately though, due to the bugginess of this whole thing, I can't safely use this library. Why can it not just use the currently running event loop?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions