ducky.interfaces module

class ducky.interfaces.IMachineWorker[source]

Bases: object

Base class for objects that provide pluggable service to others.

boot(*args)[source]

Prepare for providing the service. After this call, it may be requested by others.

die(exc)[source]

Exceptional state requires immediate termination of service. Probably no object will ever have need to call others’ die method, it’s intended for internal use only.

halt()[source]

Terminate service. It will never be requested again, object can destroy its internal state, and free allocated resources.

run()[source]

Called by reactor’s loop when this object is enqueued as a reactor task.

suspend()[source]

Suspend service. Object should somehow conserve its internal state, its service will not be used until the next call of wake_up method.

wake_up()[source]

Wake up service. In this method, object should restore its internal state, and after this call its service can be requested by others again.

class ducky.interfaces.IReactorTask[source]

Bases: object

Base class for all reactor tasks.

run()[source]

This method is called by reactor to perform task’s actions.

class ducky.interfaces.ISnapshotable[source]

Bases: object

Base class for objects that can be saved into a snapshot.

load_state(state)[source]

Restore state of the object.

Parameters:state (ducky.snapshot.SnapshotNode) – snapshot node containing saved state.
save_state(parent)[source]

Create state of the object, and attach it to a parent snapshot node.

Parameters:parent (ducky.interfaces.ISnapshotable) – parent snapshot node.
class ducky.interfaces.IVirtualInterrupt(machine)[source]

Bases: object

run(core)[source]