agora.observe.sync_service

Matrix sync-loop driver.

Wraps MatrixClientProtocol.sync_once() in an infinite loop, feeding each batch into an EventDispatcher. Cancellation-safe via stop().

Usage:

service = SyncService(client, dispatcher, rooms=[project_room])
await service.start()          # fire-and-forget background task
...
await service.stop()           # cancels cleanly

Or drive it synchronously in foreground:

await service.run()

Classes

SyncService

Owns the Matrix sync loop: repeatedly calls sync_once and feeds each batch to the EventDispatcher.

class agora.observe.sync_service.SyncService[source]

Bases: object

Owns the Matrix sync loop: repeatedly calls sync_once and feeds each batch to the EventDispatcher. start() runs it as a background task, run() in the foreground; stop() cancels cleanly (the loop is cancellation-safe, so an in-flight sync won’t leak).

__init__(client, dispatcher, rooms=None, timeout_ms=30000, poll_interval_on_error=2.0)[source]
property running: bool
property since: str | None
watch_rooms(rooms)[source]

Replace the watched-room set mid-run. Events in other rooms are dropped.

async start()[source]

Launch the sync loop as a background task. Idempotent.

async stop()[source]
async run()[source]

Drive the sync loop until stop() is called.