Frequenz-channels

Latest version: v1.2.0

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

Scan your dependencies

Page 3 of 4

0.15.0

Frequenz Channels Release Notes

Summary

This release adds support to pass `None` values via channels and revamps the `Timer` class to support custom policies for handling missed ticks and use the loop monotonic clock. There is also a fix for the `FileWatcher` which includes a change in behavior when reporting changes for deleted files.

Upgrading

* `util.Timer` was replaced by a more generic implementation that allows for customizable policies to handle missed ticks.

If you were using `Timer` to implement timeouts, these two pieces of code should be almost equivalent:

- Old:

python
old_timer = Timer(1.0)
triggered_datetime = old_timer.receive()


- New:

python
new_timer = Timer.timeout(timedelta(seconds=1.0))
drift = new_timer.receive()
triggered_datetime = datetime.now(timezone.utc) - drift


They are not **exactly** the same because the `triggered_datetime` in the second case will not be exactly when the timer had triggered, but that shouldn't be relevant, the important part is when your code can actually react to the timer trigger and to know how much drift there was to be able to take corrective actions.

Also the new `Timer` uses the `asyncio` loop monotonic clock and the old one used the wall clock (`datetime.now()`) to track time. This means that when using `async-solipsism` to test, the new `Timer` will always trigger immediately regardless of the state of the wall clock. This also means that we don't need to mock the wall clock with `time-machine` either now.

With the previous timer one needed to create a separate task to run the timer, because otherwise it would block as it loops until the wall clock was at a specific time. Now the code will run like this:

python
timer = Timer.timeout(timedelta(seconds=1.0))
asyncio.sleep(0.5) Advances the loop monotonic clock by 0.5 seconds immediately
await drift = timer.receive() Advances the clock by 0.5 immediately too
assert drift == approx(timedelta(0)) Because it could trigger exactly at the tick time

Simulates a delay in the timer trigger time
asyncio.sleep(1.5) Advances the loop monotonic clock by 1.5 seconds immediately
await drift = timer.receive() The timer should have triggered 0.5 seconds ago, so it doesn't even sleep
assert drift == approx(timedelta(seconds=0.5)) Now we should observe a drift of 0.5 seconds


**Note:** Before replacing this code blindly in all uses of `Timer.timeout()`, please consider using the periodic timer constructor `Timer.periodic()` if you need a timer that triggers reliable on a periodic fashion, as the old `Timer` (and `Timer.timeout()`) accumulates drift, which might not be what you want.

* `FileWatcher` now will emit events even if the file doesn't exist anymore.

Because the underlying library has a considerable delay in triggering filesystem events, it can happen that, for example, a `CREATE` event is received but at the time of receiving the file doesn't exist anymore (because if was removed just after creation and before the event was triggered).

Before the `FileWatcher` will only emit events when the file exists, but this doesn't work for `DELETE` events (clearly). Given the nature of this mechanism can lead to races easily, it is better to leave it to the user to decide when these situations happen and just report all events.

Therefore, you should now check a file receiving an event really exist before trying to operate on it.

* `FileWatcher` reports the type of event observed in addition to the file path.

Previously, only the file path was reported. With this update, users can now determine if a file change is a creation, modification, or deletion.
Note that this change may require updates to your existing code that relies on `FileWatcher` as the new interface returns a `FileWatcher.Event` instead of just the file path.

New Features

* `util.Timer` was replaced by a more generic implementation that allows for customizable policies to handle missed ticks.

* Passing `None` values via channels is now supported.

* `FileWatcher.Event` was added to notify events when a file is created, modified, or deleted.

Bug Fixes

* `util.Select` / `util.Merge` / `util.MergeNamed`: Cancel pending tasks in `__del__` methods only if possible (the loop is not already closed).

* `FileWatcher` will now report `DELETE` events correctly.

Due to a bug, before this release `DELETE` events were only reported if the file was re-created before the event was triggered.


What's Changed
* Clear release notes by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/81
* Publish to PyPi using trusted publishing by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/84
* Add support/tests for None-value channels by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/83
* Cancel pending tasks in `__del__` methods only if possible by sahas-subramanian-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/85
* Make the timer generic and support periodic timers by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/79
* Fix `FileWatcher` `DELETE` event reporting and rearrange tests by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/86
* Report the type of change observed in FileWatcher by daniel-zullo-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/87

New Contributors
* sahas-subramanian-frequenz made their first contribution in https://github.com/frequenz-floss/frequenz-channels-python/pull/83
* daniel-zullo-frequenz made their first contribution in https://github.com/frequenz-floss/frequenz-channels-python/pull/87

**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.14.0...v0.15.0

0.14.0

Frequenz Channels Release Notes

Summary

The main change in this release is the revamp of exception handling in general. New exceptions were created and `send()` now raises an exception too when it fails.

Hopefully they are now used much more uniformly across the whole library.

Upgrading

* The `Sender.send()` method now `raise`s a `SenderError` instead of returning `False`. The `SenderError` will typically have a `ChannelClosedError` and the underlying reason as a chained exception.

* The `Receiver.ready()` method (and related `receive()` and `__anext__` when used as an async iterator) now `raise`s a `ReceiverError` and in particular a `ReceiverStoppedError` when the receiver has no more messages to receive.

`Receiver.consume()` doesn't raise any exceptions.

Receivers raising `EOFError` now raise `ReceiverInvalidatedError` instead.

* For channels which senders raise an error when the channel is closed or which receivers stop receiving when the channel is closed, the `SenderError` and `ReceiverStoppedError` are chained with a `__cause__` that is a `ChannelClosedError` with the channel that was closed.

* `ChannelClosedError` now requires the argument `channel` (before it was optional).

* Now exceptions are not raised in Receiver.ready() but in Receiver.consume() (receive() or the async iterator `anext`).

New Features

* New exceptions were added:

* `Error`: A base exception from which all exceptions from this library inherit.

* `SendError`: Raised for errors when sending messages.

* `ReceiverError`: Raised for errors when receiving messages.

* `ReceiverClosedError`: Raised when a receiver don't have more messages to receive.

* `ReceiverInvalidatedError`: Raised when a receiver was invalidated (for example it was converted into a `Peekable`).


What's Changed
* Clean release notes by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/69
* Fix build badge by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/71
* Improve and add exceptions by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/61
* Make assert msg grammatically correct and less ambiguous by mathias-baumann-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/74
* Finish release notes for v0.14.0 by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/80

New Contributors
* mathias-baumann-frequenz made their first contribution in https://github.com/frequenz-floss/frequenz-channels-python/pull/74

**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.13.0...v0.14.0

0.13.0

Frequenz Channels Release Notes

New Features

* Add method to stop `Merge` and `MergeNamed`.

What's Changed
* Clean release notes by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/67
* Add stop method for MergeNamed and Merge channels by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/68


**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.12.0...v0.13.0

0.12.0

Frequenz Channels Release Notes

Summary

Upgrading

New Features
* Add method to stop Select.

Bug Fixes

* Deactivate Broadcast receivers that were transformed to peekable.



What's Changed
* Clear release notes by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/58
* Add method to stop Select by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/63
* Add a private method to deactivate Broadcast receivers by shsms in https://github.com/frequenz-floss/frequenz-channels-python/pull/64
* Update release notes by ela-kotulska-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/65

New Contributors
* ela-kotulska-frequenz made their first contribution in https://github.com/frequenz-floss/frequenz-channels-python/pull/63

**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.11.0...v0.12.0

0.11.0

Frequenz Channels Release Notes

Summary

The project has a new home!

https://frequenz-floss.github.io/frequenz-channels-python/

For now the documentation is pretty scarce but we will be improving it with time.

Upgrading (breaking changes)

* You need to make sure to use [timezone-aware] `datetime` objects when using the timestamp returned by [`Timer`], Otherwise you will get an exception.

* Channels methods `get_receiver()` and `get_sender()` have been renamed to `new_receiver()` and `new_sender()` respectively. This is to make it more clear that new objects are being created.

* The public API surface has been reduced considerably to make it more clear where to import symbols. You should update your imports. The new symbol locations are:

* `frequenz.channels.Anycast`
* `frequenz.channels.Broadcast`
* `frequenz.channels.Anycast`
* `frequenz.channels.Bidirectional`
* `frequenz.channels.Broadcast`
* `frequenz.channels.Peekable`
* `frequenz.channels.Receiver`
* `frequenz.channels.Sender`
* `frequenz.channels.util.Merge`
* `frequenz.channels.util.MergeNamed`
* `frequenz.channels.util.FileWatcher`
* `frequenz.channels.util.Select`
* `frequenz.channels.util.Timer`

* The class `BufferedReceiver` was removed because the interface was really intended for channel implementations. Users are not supposed to enqueue messages to receiver but just receive from them. If you used it you can implement it yourself.

* The class `BidirectionalHandle` was moved to `Bidirectional.Handle`.

* The class `EventType` was moved to `FileWatcher.EventType`.

New Features

* Python 3.11 is now supported!

Bug Fixes

* [`Broadcast`] receivers now get cleaned up once they go out of scope.

* [`Timer`] now returns [timezone-aware] `datetime` objects using UTC as timezone.

[`Broadcast`]: https://frequenz-floss.github.io/frequenz-channels-python/v0.11/reference/frequenz/channels/#frequenz.channels.Broadcast
[`Timer`]: https://frequenz-floss.github.io/frequenz-channels-python/v0.11/reference/frequenz/channels/#frequenz.channels.Timer
[timezone-aware]: https://docs.python.org/3/library/datetime.html#aware-and-naive-objects


What's Changed
* Fix project URLs by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/18
* ci: Test also Python 3.11 pre-releases by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/19
* Remove `version:xxx` and add `part:select` and `part:receivers` labels by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/28
* Use MkDocs to build the documentation by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/25
* ci: Add contents permission to publish-docs by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/33
* ci: Update aliases when deploying with mike by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/38
* Add PyPI and Docs badges to README by shsms in https://github.com/frequenz-floss/frequenz-channels-python/pull/34
* ci: Use the final Python 3.11 version by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/39
* docs: Replace the Home with the README by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/40
* Fix CONTRIBUTING headings by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/41
* Use "aware" datetimes by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/48
* Ensure deleted receivers get cleaned up by shsms in https://github.com/frequenz-floss/frequenz-channels-python/pull/45
* Avoid dropping of messages after breaking from `Select` blocks by shsms in https://github.com/frequenz-floss/frequenz-channels-python/pull/42
* Rename `get_{sender,receiver}` to `new_{sender,receiver}` by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/49
* Clean up public API by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/55
* FileWatcher: Don't type-check `changes` by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/56
* Add Python 3.11 support to RELEASE_NOTES by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/57


**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.10.0...v0.11.0

0.10.1

`frequenz-channels` Release Notes

Summary

This is the first public open source release based on the internal SDK version v0.9.0. There are no breaking changes in this release, only changes to the project structure, metadata, and automation. Packages are also now uploaded to PyPI as [`frequenz-channels`](https://pypi.org/project/frequenz-channels/), so this project now can be installed normally via `pip`:

sh
python -m pip install frequenz-channels


The GitHub issues were also improved, adding templates for [reporting issues](https://github.com/frequenz-floss/frequenz-channels/issues/new?assignees=&labels=priority%3A%E2%9D%93%2C+type%3Abug&template=bug.yml) and [requesting features](https://github.com/frequenz-floss/frequenz-channels/issues/new?assignees=&labels=part%3A%E2%9D%93%2C+priority%3A%E2%9D%93%2C+type%3Aenhancement&template=feature.yml). Users are also pointed to the [Discussion forums](https://github.com/frequenz-floss/frequenz-channels/issues/new/choose) when trying to open an issue if they have questions instead. Also many labels are assigned automatically on issue and pull request creation.


What's Changed
* Backport documentation generation to v0.10.x by leandro-lucarella-frequenz in https://github.com/frequenz-floss/frequenz-channels-python/pull/35


**Full Changelog**: https://github.com/frequenz-floss/frequenz-channels-python/compare/v0.10.0...v0.10.1

Page 3 of 4

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.