Mode

Latest version: v4.4.0

Safety actively analyzes 629599 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 13 of 15

1.10.0

======
:release-date: 2018-03-30 12:36 P.M PST
:release-by: Ask Solem

- New supervisor: :class:`~mode.supervisors.ForfeitOneForOneSupervisor`.

If a service in the group crashes we give up on that service
and don't start it again.

- New supervisor: :class:`~mode.supervisor.ForfeitOneForAllSupervisor`.

If a service in the group crashes we give up on it, but also
stop all services in the group and give up on them also.

- Service Logging: Renamed ``self.log.crit`` to ``self.log.critical``.

The old name is still available and is not deprecated at this time.


.. _version-1.9.2:

1.9.2

=====
:release-date: 2018-03-20 10:17 P.M PST
:release-by: Ask Solem

- Adds ``FlowControlEvent.clear()`` to clear all contents of flow
controlled queues.

- :class:`~mode.utils.futures.FlowControlEvent` now starts in a suspended
state.

To disable this pass ``FlowControlEvent(initially_suspended=False))``.

- Adds ``Service.service_reset`` method to reset service
start/stopped/crashed/etc., flags

.. _version-1.9.1:

1.9.1

=====
:release-date: 2018-03-05 11:51 P.M PST
:release-by: Ask Solem

- No longer depends on :pypi:`terminaltables`.

.. _version-1.9.0:

1.9.0

=====
:release-date: 2018-03-05 11:33 P.M PST
:release-by: Ask Solem

Backward Incompatible Changes
=============================

- Module ``mode.utils.debug`` renamed to :mod:`mode.debug`.

This is unlikely to affect users as this module is only used by mode
internally.

This module had to move because it imports ``mode.Service``, and
the :mod:`mode.utils` package is not allowed to import from the
:mod:`mode` package at all.

News
====

- Added function :func:`mode.utils.import.smart_import`.

- Added non-async version of :class:`mode.Signal`: :class:`mode.SyncSignal`.

The signal works exactly the same as the asynchronous version, except
``Signal.send`` must not be :keyword:`await`-ed::

on_configured = SyncSignal()
on_configured.send(sender=obj)


- Added method ``iterate`` to :class:`mode.utils.imports.FactoryMapping`.

This enables you to iterate over the extensions added to a
:mod:`setuptools` entrypoint.

Fixes
=====

- ``StampedeWrapper`` now correctly clears flag when original call done.

.. _version-1.8.0:

1.8.0

=====
:release-date: 2018-02-20 04:01 P.M PST
:release-by: Ask Solem

Backward Incompatible Changes
-----------------------------

- API Change to fix memory leak in ``Service.wait``.

The ``Service.wait(*futures)`` method was added to be able to wait for
this list of futures but also stop waiting if the service is stopped or
crashed::

import asyncio
from mode import Service

class X(Service):
on_thing_ready: asyncio.Event

def __post_init__(self):
self.on_thing_ready = asyncio.Event(loop=loop)

Service.task
async def _my_background_task(self):
while not self.should_stop:
wait for flag to be set (or service stopped/crashed)
await self.wait(self.on_thing_ready.wait())
print('FLAG SET')

The problem with this was

1) The wait flag would return None and not raise an exception if the
service is stopped/crashed.
2) Futures would be scheduled on the event loop but not properly cleaned
up, creating a very slow memory leak.
3) No return value was returned for succesful feature.

So to properly implement this we had to change the API of the ``wait``
method to return a tuple instead, and to only allow a single coroutine to
be passed to wait::

Service.task
async def _my_background_task(self):
while not self.should_stop:
wait for flag to be set (or service stopped/crashed)
result, stopped = await self.wait(self.on_thing_ready)
if not stopped:
print('FLAG SET')

This way the user can provide an alternate path when the service is
stopped/crashed while waiting for this event.

A new shortcut method ``wait_for_stopped(fut)`` was also added::

wait for flag to be set (or service stopped/crashed)
if not await self.wait_for_stopped(self.on_thing_ready):
print('FLAG SET')

Moreover, you can now pass :class:`asyncio.Event` objects directly to
``wait()``.

News
----

- Added :class:`mode.utils.collections.DictAttribute`.

- Added :class:`mode.utils.collections.AttributeDict`.

Bugs
----

- Signals can create clone of signal with default sender already set

.. code-block:: python

signal: Signal[int] = Signal()
signal = signal.with_default_sender(obj)

.. _version-1.7.0:

1.7.0

=====
:release-date: 2018-02-05 12:28 P.M PST
:release-by: Ask Solem

- Adds :mod:`mode.utils.aiter` for missing ``aiter`` and ``anext`` functions.

- Adds :mod:`mode.utils.futures` for :class:`asyncio.Task` related tools.

- Adds :mod:`mode.utils.collections` for custom mapping/set and list
data structures.

- Adds :mod:`mode.utils.imports` for importing modules at runtime,
as well as utilities for typed :mod:`setuptools` entry-points.

- Adds :mod:`mode.utils.text` for fuzzy matching user input.

.. _version-1.6.0:

Page 13 of 15

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.