v1.0.0-rc.1
Pre-releaseFrequenz channels Release Notes
Summary
This is the first release candidate for version 1.0. It includes few new features and a lot of cleanups and API improvements and polishing. Because of this, there are a lot of breaking changes too, but they should be easy to fix, as they ae mostly renames and reorganizations.
We hope this is the final pre-release before the final 1.0 release, and we don't expect to introduce any further breaking changes. Because of this we encourage you to test it and report any issues you find. You can also use a version constraint like >= 1.0.0-rc.1, < 2.0.0
as the final version should be compatible.
Upgrading
-
Anycast
-
__init__
: Themaxsize
argument was renamed tolimit
and made keyword-only and a new keyword-onlyname
argument was added.You should instantiate using
Anycast(name=..., limit=...)
(orAnycast(name=...)
if the defaultlimit
is enough) instead ofAnycast(...)
orAnycast(maxsize=...)
. -
new_sender
andnew_receiver
: They now return a baseSender
andReceiver
class (respectively) instead of a channel-specificSender
orReceiver
subclass.This means users now don't have access to the internals to the channel-specific
Sender
andReceiver
subclasses.
-
-
Broadcast
-
__init__
: Thename
argument was made optional and keyword-only;resend_latest
was also made keyword-only. If aname
is not specified, it will be generated from theid()
of the instance.You should instantiate using
Broadcast(name=name, resend_latest=resend_latest)
(orBroadcast()
if the defaults are enough) instead ofBroadcast(name)
orBroadcast(name, resend_latest)
. -
new_receiver
: Themaxsize
argument was renamed tolimit
and made keyword-only; thename
argument was also made keyword-only. If aname
is not specified, it will be generated from theid()
of the instance instead of a random UUID.You should use
.new_receiver(name=name, limit=limit)
(or.new_receiver()
if the defaults are enough) instead of.new_receiver(name)
or.new_receiver(name, maxsize)
. -
new_sender
andnew_receiver
now return a baseSender
andReceiver
class (respectively) instead of a channel-specificSender
orReceiver
subclass.This means users now don't have access to the internals to the channel-specific
Sender
andReceiver
subclasses.
-
-
Event
-
__init__
: Thename
argument was made keyword-only. The default was changed to a more readable version ofid(self)
.You should instantiate using
Event(name=...)
instead ofEvent(...)
. -
Moved from
frequenz.channels.util
tofrequenz.channels.event
.
-
-
FileWatcher
-
Moved from
frequenz.channels.util
tofrequenz.channels.file_watcher
. -
Support classes are no longer nested inside
FileWatcher
. They are now top-level classes within the newfrequenz.channels.file_watcher
module (e.g.,frequenz.channels.util.FileWatcher.EventType
->frequenz.channels.file_watcher.EventType
,frequenz.channels.util.FileWatcher.Event
->frequenz.channels.file_watcher.Event
).
-
-
Receiver
- The
map()
function now takes a positional-only argument, if you were usingreceiver.map(call=fun)
you should replace it withreceiver.map(func)
.
- The
-
SelectError
now inherits fromchannels.Error
instead ofBaseException
, so you should be able to catch it withexcept Exception:
orexcept channels.Error:
. -
Selected
- The
value
property was renamed tomessage
. was_stopped
is now a property, you need to replaceselected.was_stopped()
withselected.was_stopped
.
- The
-
Sender
- The
send
method now takes a positional-only argument, if you were usingsender.send(msg=message)
you should replace it withsender.send(message)
.
- The
-
Timer
and support classes- Moved from
frequenz.channels.util
tofrequenz.channels.timer
.
- Moved from
-
All exceptions that took
Any
as themessage
argument now takestr
instead.If you were passing a non-
str
value to an exception, you should convert it usingstr(value)
before passing it to the exception. -
The following symbols were moved to the top-level
frequenz.channels
package:Selected
SelectError
UnhandledSelectedError
select
selected_from
Removals
-
Bidirectional
This channel was removed as it is not recommended practice and was a niche use case. If you need to use it, you can set up two channels or copy the
Bidirectional
class from the previous version to your project. -
Merge
Replaced by the new
merge()
function. When replacingMerge
withmerge()
please keep in mind that this new function will raise aValueError
if no receivers are passed to it.Please note that the old
Merge
class is still also available but it was renamed toMerger
to avoid confusion with the newmerge()
function, but it is only present for typing reasons and should not be used directly. -
MergeNamed
This class was redundant, use either the new
merge()
function orselect()
instead. -
Peekable
This class was removed because it was merely a shortcut to a receiver that caches the last message received. It did not fit the channel abstraction well and was infrequently used.
You can replace it with a task that receives and retains the last message.
-
Broadcast.new_peekable()
This was removed alongside
Peekable
. -
Receiver.into_peekable()
This was removed alongside
Peekable
. -
ReceiverInvalidatedError
This was removed alongside
Peekable
(it was only raised when using aReceiver
that was converted into aPeekable
). -
SelectErrorGroup
was removed, a Python built-inBaseExceptionGroup
is raised instead in case of unexpected errors while finalizing aselect()
loop, which will be automatically converted to a simpleExceptionGroup
when no exception in the groups is aBaseException
.
-
Timer
:-
periodic()
andtimeout()
: The names proved to be too confusing, please useTimer()
and pass a missing ticks policy explicitly instead. In general you can update your code by doing:Timer.periodic(interval)
/Timer.periodic(interval, skip_missed_ticks=True)
->Timer(interval, TriggerAllMissed())
Timer.periodic(interval, skip_missed_ticks=False)
->Timer(interval, SkipMissedAndResync())
Timer.timeout(interval)
->Timer(interval, SkipMissedAndDrift())
-
-
util
The entire
util
package was removed and its symbols were either moved to the top-level package or to their own public modules (as noted above).
New Features
-
A new User's Guide was added to the documentation and the documentation was greately improved in general.
-
A new
merge()
function was added to replaceMerge
. -
Anycast
-
The following new read-only properties were added:
name
: The name of the channel.limit
: The maximum number of messages that can be sent to the channel.is_closed
: Whether the channel is closed.
-
A more useful implementation of
__str__ and
repr` were added for the channel and its senders and receivers. -
A warning will be logged if senders are blocked because the channel buffer is full.
-
-
Bidirectional
-
The following new read-only properties were added:
name
: The name of the channel (read-only).is_closed
: Whether the channel is closed (read-only).
-
A more useful implementation of
__str__ and
repr` were added for the channel and the client and service handles.
-
-
Broadcast
-
The following new read-only properties were added:
name
: The name of the channel.is_closed
: Whether the channel is closed.
-
A more useful implementation of
__str__ and
repr` were added for the channel and the client and service handles.
-
-
FileWatcher
- A more useful implementation of
__str__ and
repr` were added.
- A more useful implementation of
-
Peekable
- A more useful implementation of
__str__ and
repr` were added.
- A more useful implementation of
-
Receiver
map()
: The returned map object now has a more useful implementation of__str__ and
repr`.
Improvements
-
Receiver
,merge
/Merger
,Error
and its derived classes now use a covariant generic type, which allows the generic type to be broader than the actual type. -
Sender
now uses a contravariant generic type, which allows the generic type to be narrower than the required type. -
ChannelError
is now generic, so when accessing thechannel
attribute, the type of the channel is preserved. -
The generated documentation / website was greatly improved, both in content and looks.
Bug Fixes
Timer
: Fix bug that was causing calls toreset()
to not reset the timer, if the timer was already being awaited.
What's Changed
- Update to repo-config v0.7.2 by @llucax in #230
- Bump the optional group with 5 updates by @dependabot in #229
- Clean up and improve the code and public interface by @llucax in #231
- Revamp modules structure by @llucax in #235
- Replace
Merge
andMergeNamed
withmerge()
by @llucax in #238 - Clear release notes by @llucax in #240
- Fix timer
reset()
while it is being waited on by @llucax in #241 - Fix typo in comment by @llucax in #247
- Make
Merge
public again and rename it toMerger
by @llucax in #243 - Add some useful mkdocs extensions by @llucax in #244
- dependabot/pip/optional 62c46a5f26 by @Marenz in #255
- Add a User Guide by @llucax in #245
- Bump actions/setup-python from 4 to 5 by @dependabot in #257
- Bump the optional group with 10 updates by @dependabot in #261
- Support broadening or narrowing of types in
Receiver
s andSender
s by @shsms in #262 Timer
: Removeperiodic()
andtimeout()
by @llucax in #264- Bump actions/cache from 3 to 4 by @dependabot in #270
- Bump black from 23.12.1 to 24.1.1 by @dependabot in #269
- Bump flake8 from 6.1.0 to 7.0.0 by @dependabot in #267
- Bump types-markdown from 3.5.0.3 to 3.5.0.20240129 by @dependabot in #266
- Bump the optional group with 5 updates by @dependabot in #265
- Bump actions/labeler from 4.3.0 to 5.0.0 by @dependabot in #259
- Add a tip about the returned receiver type for
map()
by @llucax in #271 - Remove boilerplate from examples in the user guide by @llucax in #276
- Bump the optional group with 9 updates by @dependabot in #277
- Bump actions/upload-artifact from 3 to 4 by @dependabot in #258
- Bump pytest from 7.4.4 to 8.1.0 by @dependabot in #278
- Use the new set of labels by @llucax in #274
- Enable and use GitHub Alert syntax for admonitions by @llucax in #275
- Improve documentation by @llucax in #279
- Rename "value" to "message" and other minor breaking changes by @llucax in #281
- Improve
select()
-related exceptions by @llucax in #283 - Improve generics usage by @llucax in #282
- Prepare release notes for 1.0.0-rc.1 by @llucax in #284
Full Changelog: v1.0.0-beta.1...v1.0.0-rc.1