Skip to content

Websockets & Event hub - #366

Merged
iLLiCiTiT merged 16 commits into
developfrom
enhancement/event-hub
Oct 15, 2026
Merged

iLLiCiTiT merged 16 commits into
developfrom
enhancement/event-hub

Conversation

@iLLiCiTiT

@iLLiCiTiT iLLiCiTiT commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Changelog Description

Added websockets and event hub to ayon api.

Additional review information

Added simple way how to start websocket communication. Also added helper EventHub that does handle registering of handler for events.

Almost same implementation of event hub was added to core in ynput/ayon-core#2178 . This is meant to replace that when needed version of AYON launcher with this python api is required by ayon-core addon.

Testing notes:

The easiest way is to get event hub from ayon api and register callbacks to known topics for example creation of folder.

Example

import ayon_api

event_hub = ayon_api.get_event_hub()

def my_callback(event):
    print(event)
    event_hub.stop()

event_hub.add_callback("entity.folder.created", my_callback)
event_hub.start()
while event_hub.is_running():
    time.sleep(0.1)

Resolves ynput/ayon-core#1386

@iLLiCiTiT iLLiCiTiT self-assigned this Oct 12, 2026
@iLLiCiTiT iLLiCiTiT added the type: enhancement New feature or request label Oct 12, 2026
@iLLiCiTiT
iLLiCiTiT requested a review from BigRoy October 12, 2026 14:45
@BigRoy
BigRoy requested review from antirotor and rdelillo October 12, 2026 22:59
- Token change ('set_token', 'reset_token', 'login', 'logout')
  re-authenticates the websocket and wakes the hub from auth failure
  backoff.
- 'ServerAPI' creates its hub on demand.
- 'EventHub' requires connection.
- One 'atexit' callback stops all hubs, hubs are stored weakly so stopped
  hubs and their connections can be garbage collected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rdelillo rdelillo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, got the provided example working in a venv.

@iLLiCiTiT
iLLiCiTiT merged commit d417ce4 into develop Oct 15, 2026
3 checks passed
@iLLiCiTiT
iLLiCiTiT deleted the enhancement/event-hub branch October 15, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect when server connectivity is lost or regained

2 participants