m4us.core.schedulers

Provides a variety of scheduler classes to coordinate coroutines.

Schedulers are responsible for the main program loop, cycling through each registered coroutine in turn. They also send post office messages into the registered coroutines and post emitted messages back to the post office.

Inheritance Diagram

Inheritance diagram of m4us.core.schedulers

Members

class Scheduler(post_office, add_ignores_duplicates=False, remove_ignores_missing=False)[source]

Bases: object

The standard scheduler class to run coroutines.

This is a simple and reasonably efficient implementation of IScheduler. Unless you have a special need, this is this probably scheduler you want to use.

Parameters:post_office (m4us.core.interfaces.IPostOffice) -- The post office object to use for message routing.
Raises exceptions.TypeError:
 If the given post office does not provide or cannot be adapted to IPostOffice.
Implements :m4us.core.interfaces.IScheduler
Provides :m4us.core.interfaces.ISchedulerFactory

See also

The IPostOffice interface for details on post offices.

cycle()[source]

Cycle once through the main loop, running all eligible coroutines.

Warning

The current implementation of this method can handle a shrinking run queue due to coroutines shutting down, but it has not yet been designed to handle the dynamic adding or removing of coroutines within a the cycle execution. It's behaviour in those situations is currently undefined.

See also

The IScheduler interface for details about this method.

See also

The step() method for details how the coroutines are run.

register(first_coroutine, *other_coroutines)[source]

Register one or more coroutines with the scheduler.

See also

The IScheduler interface for details about this method.

run(cycles=None)[source]

Start the scheduler, running all registered coroutines.

Warning

If cycles is not specified and any of the coroutines do not cascade IShutdown messages or shutdown properly, then this method will likely loop forever.

See also

The IScheduler interface for details about this method.

See also

The cycle() method for details how the coroutines are run.

See also

The IShutdown interface for details on shutdown messages.

step()[source]

Run one coroutine.

Note

Coroutines are run in a round-robin style, in the order that they have been added. Coroutines should not, however, rely on this implementation detail.

See also

The IScheduler interface for details about this method.

unregister(first_coroutine, *other_coroutines)[source]

Unregister one or more coroutines from the scheduler.

See also

The IScheduler interface for details about this method.

Table Of Contents

Previous topic

m4us.core.postoffices

Next topic

m4us.core.utils

This Page