services.backoff_state module

Persistent GitHub backoff state management.

Backoff is a global switch to reduce GitHub API traffic when nearing rate limits or during maintenance. State is persisted in the DB so it survives restarts, with an in-memory cache for fast reads.

services.backoff_state.emit_event(event, severity='info', **fields)[source]
Parameters:
class services.backoff_state.BackoffInfo(enabled, reason='', updated_at=datetime.datetime(2026, 5, 15, 19, 14, 18, 626172, tzinfo=datetime.timezone.utc), expires_at=None)[source]

Bases: object

Parameters:
enabled: bool
reason: str = ''
updated_at: datetime = datetime.datetime(2026, 5, 15, 19, 14, 18, 626172, tzinfo=datetime.timezone.utc)
expires_at: Optional[datetime] = None
is_active()[source]
Return type:

bool

__init__(enabled, reason='', updated_at=datetime.datetime(2026, 5, 15, 19, 14, 18, 626172, tzinfo=datetime.timezone.utc), expires_at=None)
Parameters:
Return type:

None

class services.backoff_state.BackoffState[source]

Bases: object

Backoff state persisted in DB with memory cache.

__init__()[source]
Return type:

None

get(refresh=False)[source]
Return type:

BackoffInfo

Parameters:

refresh (bool)

enable(*, reason='', ttl_minutes=None)[source]
Return type:

BackoffInfo

Parameters:
  • reason (str)

  • ttl_minutes (int | None)

disable(*, reason='')[source]
Return type:

BackoffInfo

Parameters:

reason (str)

toggle(*, reason='', ttl_minutes=None)[source]
Return type:

BackoffInfo

Parameters:
  • reason (str)

  • ttl_minutes (int | None)