schedr.runner.waiting

How a wait step waits: until its value or its deadline (see schedr.sensors).

exception schedr.runner.waiting.ProcessInWaitStepError

Bases: RuntimeError

A wait step tried to start a process (decision 336).

exception schedr.runner.waiting.StepEndedError

Bases: BaseException

Raised in a wait step’s asyncio.to_thread call when its time is up (decision 337).

As asyncio.CancelledError, not an Exception: except Exception doesn’t keep it going.

schedr.runner.waiting.OVERRUN_LIMIT = 3

How many times every one call of a sensor’s poke may run before it is cancelled and fails the attempt (the user’s number, 2026-11-12: a hard limit on one overrun).

schedr.runner.waiting.set_poke_overruns(times)

Sets [watchers] poke_overruns for this process’s sensor pokes (0 counts as 1).

Parameters:

times (int)

Return type:

None

schedr.runner.waiting.refuse_a_process()

Refuses to start a process, in a wait step’s function.

Raises:

ProcessInWaitStepError – When this code runs for one.

Return type:

None

exception schedr.runner.waiting.WatcherMovedError

Bases: Exception

A poke stopped between calls: its next one is made on new code (decision 335).

exception schedr.runner.waiting.PokeTooSlowError

Bases: Exception

A @sensor.poke ran past every too often, or a call ran three times it (D458).

exception schedr.runner.waiting.CallTimedOutError

Bases: Exception

An @sensor(wait_for=...)’s call ran out its timeout (decision 353).

exception schedr.runner.waiting.CallStuckError

Bases: Exception

A trigger’s poke call past its time left a thread that didn’t stop (decision 489).

schedr.runner.waiting.set_settled(settled)

Sets how a trigger’s poke waits for a failed call’s threads (the host’s, at its start).

Parameters:

settled (Callable[[], Awaitable[bool]])

Return type:

None

schedr.runner.waiting.awaited_poke(function)

A poke as a coroutine function: an async def as it is, a plain def on threads.

A plain def is called on the host’s threads (decision 489). A plain call runs as asyncio.to_thread does, so it is its wait step’s (its context, log and secrets) and is stopped as such a call is when its time is up (decision 337); what it returns, if a coroutine (a plain wrapper of an async def), is awaited.

Parameters:

function (Callable[..., object]) – The poke’s function.

Returns:

A function whose call is a coroutine of what the poke returns.

Return type:

Callable[…, Coroutine[object, object, object]]

async schedr.runner.waiting.waited(function, arguments, task, moving=None)

Runs a wait step to its end.

Parameters:
  • function (Callable[..., Coroutine[object, object, object]]) – The wait step’s function.

  • arguments (Mapping[str, object]) – Its arguments.

  • task (Mapping[str, object]) – The task as DAG JSON: its every_ms and max_wait_ms.

  • moving (asyncio.Event | None) – Set when a poke is to stop between its calls; None: it never is.

Returns:

Its value, or TimedOut() if its time ran out.

Raises:
  • PokeTooSlowError – If a @sensor.poke’s calls ran past every [watchers]     poke_overruns times in a row, or one ran three times it.

  • CallTimedOutError – If an @sensor(wait_for=...) call ran out its timeout.

  • WatcherMovedError – If moving was set before a value came.

Return type:

object

class schedr.runner.waiting.Batch(seconds, size, limit)

Bases: object

An @trigger.poke(batch=...)’s window (decision 352).

Parameters:
  • seconds (float)

  • size (Callable[[Event[Any]], int])

  • limit (int)

seconds

How long it gathers from the first item.

Type:

float

size

An item’s size as stored, in bytes; one that can’t be stored is given as over limit, so it goes alone and fails when it is told, as it would unbatched.

Type:

Callable[[Event[Any]], int]

limit

The most one event’s data may take: its max_output_size.

Type:

int

schedr.runner.waiting.batched(items)

One event for a window’s items: the last one’s key, the items as its data (decision 352).

Returns:

The event to tell.

Parameters:

items (list[Event[Any]])

Return type:

Event[Any]

async schedr.runner.waiting.run_trigger(function, arguments, task, after, tell, poked, batch=None)

Calls a trigger’s function, telling each event found; returns when a generator does.

Parameters:
  • function (Callable[..., object]) – The function.

  • arguments (Mapping[str, object]) – Its arguments, without after.

  • task (Mapping[str, object]) – Its task: called every every_ms, if it has that.

  • after (str | None) – The last key acted on.

  • tell (Callable[[Event[Any]], Awaitable[None]]) – Tells an event and waits until it is safe: the next one’s order is kept.

  • poked (Callable[[str | None], None]) – Told how each call of a poke ended: why it failed, if it did.

  • batch (Batch | None) – A poke’s batch= window, if it has one.

Return type:

None