fermilink.runner.admission module

exception fermilink.runner.admission.QueueFullError[source]

Bases: RuntimeError

Raised when the pending-run admission queue is full.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
add_note(object, /)

Exception.add_note(note) – add a note to the exception

args
with_traceback(object, /)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class fermilink.runner.admission.RunAdmissionController[source]

Bases: object

In-memory admission queue for global/per-user run concurrency limits.

__init__(*, global_limit, per_user_limit, max_queue_size=0, max_pending_per_user=0)[source]
Parameters:
  • global_limit (int)

  • per_user_limit (int)

  • max_queue_size (int)

  • max_pending_per_user (int)

Return type:

None

async acquire(user_key)[source]

Acquire admission for a run, queueing when limits are saturated.

Parameters:

user_key (str | None)

Return type:

dict[str, int | bool]

async release(user_key)[source]

Release one active slot and admit queued work if possible.

Parameters:

user_key (str | None)

Return type:

None

async snapshot()[source]

Return current queue/accounting counters (for tests/diagnostics).

Return type:

dict[str, int]

async snapshot_for_user(user_key)[source]

Return current queue/accounting counters for one normalized user key.

Parameters:

user_key (str or None) – User identifier to inspect.

Returns:

Snapshot containing global/per-user counters and can_run_now.

Return type:

dict[str, int | bool]