morphogen.stopping

Cooperative stops of long computations.

A thread that runs a computation it may have to stop (a job of the interface) runs it under stoppable() with an event; the long loops of morphoGen (the iterations of the conjugate gradients, the realizations of a run, the steps the tools of the interface report) call checkpoint(), which raises Stopped once the event is set. A stop thus takes effect at the next checkpoint, never in the middle of a step; elsewhere (no event, another thread) checkpoint() does nothing.

Stopped derives from BaseException, as KeyboardInterrupt does, so that the handlers of Exception that fall back on another method (a GPU on the CPU, a solver on another) let it through.

exception morphogen.stopping.Stopped[source]

Bases: BaseException

A computation asked to stop (raised by checkpoint()).

morphogen.stopping.stoppable(event: Event) → Iterator[Event][source]

Run the block with event as the stop of the computations of this thread (the innermost when nested).

morphogen.stopping.requested() → bool[source]

Whether the computation of this thread was asked to stop.

morphogen.stopping.checkpoint() → None[source]

Raise Stopped if the computation of this thread was asked to stop.