m4us.core.schedulers — Message For You Sir! v0.2.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Message For You Sir! v0.2.1 documentation »
- API Documentation »

# `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

## Members

class `Scheduler`(post_office, add_ignores_duplicates=False, remove_ignores_missing=False)

  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 (`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 : | `IScheduler`
  Provides : | `ISchedulerFactory`

  See also

  The `IPostOffice` interface for details on post offices.

  `cycle`()

    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)

    Register one or more coroutines with the scheduler.

    See also

    The `IScheduler` interface for details about this method.

  `run`(cycles=None)

    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`()

    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)

    Unregister one or more coroutines from the scheduler.

    See also

    The `IScheduler` interface for details about this method.

### Navigation

- index
- modules |
- next |
- previous |
- Message For You Sir! v0.2.1 documentation »
- API Documentation »