m4us.core.utils — 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.utils`

Provides common utilities for the rest of the project.

## Members

`easy_link`(first_coroutine, second_coroutine, *other_coroutines)

  Return links connecting the coroutines in the standard way.

  The given coroutines are linked in a pipeline (not to be confused with a `Pipeline`) of `outbox` to `inbox` and `signal` to `control` mailboxes. The first coroutine will only have it's `outbox` and `signal` mailboxes linked and the last coroutine will only have it's `inbox` and `control` mailboxes linked. Coroutines in the middle will be linked to the previous and next coroutines in order.

  The resulting links can then be passed to a post office.

  Parameters: | first_coroutine (`ICoroutine`) -- A minimum of two coroutines are required. This is the first one. second_coroutine (`ICoroutine`) -- The second coroutine. other_coroutines (`tuple` of `ICoroutine`) -- Any other coroutines to link after the second one.
  Returns: | A set of mailbox links to be given to a post office.
  Return type: | `set` of 4-`tuple`s

  Note

  Normally one would just use the `Pipeline` class, but this provides just the links, which could be useful to other container classes.

  See also

  The `IPostOffice` interface for more information on links, mailboxes and post offices.

  See also

  The `Pipeline` class for the normal way to construct coroutine pipelines.

`is_shutdown`(inbox, message, expected_inbox=u'control')

  Return `True` if the given message signals a shutdown.

  Coroutines are expected to shutdown when they receive a shutdown message. This is a convenience function that returns `True` if inbox is `control` (by default) and the message object provides or is adaptable to `IShutdown`.

  Parameters: | inbox (`unicode`) -- The inbox in which with message was received. message (any) -- The message object that was received. expected_inbox (`unicode`) -- The inbox in which `IShutdown` messages are expected. This parameter lets the default be overridden.
  Returns: | `True` if the message signals that the coroutine should shutdown, `False` otherwise.
  Return type: | `bool`

### Navigation

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