Inspect and repair a scope#
calendaring-sync keeps everything it knows about a scope in the store, so you can read where a sync stands at any time, from any thread.
Inspect a scope#
from calendaring_sync import RecordState
scope = replica.scope(adapter.scope_id)
token, last_sync, last_listing = scope.token, scope.last_sync_at, scope.last_full_listing_at
unsent = replica.records(adapter.scope_id, states=frozenset({RecordState.PENDING}))
conflicts = replica.records(adapter.scope_id, states=frozenset({RecordState.CONFLICT}))
blocked = adapter.waiting()
The Scope says how far the last sync got and when the last full listing finished. The records in each state show what’s waiting on whom: pending edits wait for the next sync, conflicts wait for you, and waiting() lists the edits the adapter can’t send yet. The change feed shows what each sync did, as Read the change feed shows.
Repair a scope#
adapter.sync(full_listing=True)
replica.reset(adapter.scope_id)
adapter.sync()
A full listing compares every object with the server and repairs whatever an incremental sync missed. reset() forgets the scope’s sync token, so its next sync is a full listing too. Neither touches your pending edits or open conflicts. To start a scope over entirely, drop_scope() it, keep the edits it returns, and sync again.
After a server is restored from a backup, sync every scope once with a full listing. A token from after the backup is newer than anything the restored server issued, and some servers answer it as if nothing changed, as Server compatibility records.
To see the requests themselves, turn on your client library’s logging.