v1.0.0
Frequenz channels Release Notes
Summary
This is the first stable release of the Frequenz channels library.
If you are upgrading from the previous 1.0.0 pre-releases, please look into the release notes for those versions to see the changes and upgrade instructions:
There were no changes between 1.0.0-rc.1 and this 1.0.0 final release.
If you are upgrading from v0.16.x, please keep reading these release notes.
Upgrading
-
The following symbols were moved to the top-level
frequenz.channels
package:Selected
SelectError
UnhandledSelectedError
select
selected_from
-
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). -
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. -
Anycast
-
__init__
: Themaxsize
argument was renamed tolimit
and made keyword-only and a new keyword-onlyname
(required) argument was added.You should instantiate using
Anycast(name=..., limit=...)
(orAnycast(name=...)
if the defaultlimit
is enough) instead ofAnycast(...)
orAnycast(maxsize=...)
. -
The following properties were changed:
limit
: is now read-only.closed
: is now namedis_closed
and read-only.
-
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
andresend_latest
arguments were made keyword-only.You should instantiate using
Broadcast(name=name, resend_latest=resend_latest)
(orBroadcast()
if the defaults are enough) instead ofBroadcast(name)
orBroadcast(name, resend_latest)
. -
The following properties were changed:
limit
: is now read-only.closed
: is now namedis_closed
and read-only.
-
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
-
Moved from
frequenz.channels.util
tofrequenz.channels.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(...)
.
-
-
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
Removals
-
Anycast
- The following public properties were removed (made private):
deque
,send_cv
,recv_cv
.
- The following public properties were removed (made private):
-
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. -
Broadcast
- The following public properties were removed (made private):
recv_cv
,receivers
. new_peekable()
was removed becausePeekable
was removed.
- The following public properties were removed (made private):
-
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.
-
Receiver.into_peekable()
was removed becausePeekable
was removed. -
ReceiverInvalidatedError
was removed because it was only used when converting to aPeekable
andPeekable
was removed. -
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())
-
New Features
-
A new
Broadcast.resend_latest
read-write property was added to get/set whether the latest message should be resent to new receivers. -
Timer()
andTimer.reset()
now take an optionalstart_delay
option to make the timer start after some delay.This can be useful, for example, if the timer needs to be aligned to a particular time. The alternative to this would be to
sleep()
for the time needed to align the timer, but if thesleep()
call gets delayed because the event loop is busy, then a re-alignment is needed and this could go on for a while. The only way to guarantee a certain alignment (with a reasonable precision) is to delay the timer start.
Improvements
-
The arm64 architecture is now officially supported.
-
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
. -
A warning will be logged by
Anycast
channels if senders are blocked because the channel buffer is full. -
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. -
Most classes have now a better implementation of
__str__
and__repr__
.
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
- Migrate to use repo-config by @llucax in #124
- Bump pylint from 2.17.3 to 2.17.4 by @dependabot in #125
- Bump pytest-mock from 3.10.0 to 3.11.1 by @dependabot in #126
- Bump mkdocs-material from 9.1.17 to 9.1.18 by @dependabot in #128
- Bump pytest from 7.3.1 to 7.4.0 by @dependabot in #127
- Bump mypy from 1.2.0 to 1.4.1 by @dependabot in #129
- Bump hypothesis from 6.80.0 to 6.80.1 by @dependabot in #130
- Bump actions/labeler from 4.2.0 to 4.3.0 by @dependabot in #131
- Bump black from 23.3.0 to 23.7.0 by @dependabot in #132
- Bump hypothesis from 6.80.1 to 6.81.1 by @dependabot in #133
- Bump pytest-asyncio from 0.21.0 to 0.21.1 by @dependabot in #135
- Improve documentation by @llucax in #136
- Bump sybil from 5.0.2 to 5.0.3 by @dependabot in #137
- Bump hypothesis from 6.81.1 to 6.81.2 by @dependabot in #138
- Bump mkdocs-material from 9.1.18 to 9.1.19 by @dependabot in #140
- Fix typo recever -> receiver by @Marenz in #139
- Bump hypothesis from 6.81.2 to 6.82.0 by @dependabot in #141
- Bump pylint from 2.17.4 to 2.17.5 by @dependabot in #143
- Bump mkdocs-material from 9.1.19 to 9.1.21 by @dependabot in #144
- Update to repo-config 0.4.0 by @Marenz in #142
- Bump hypothesis from 6.82.0 to 6.82.2 by @dependabot in #147
- Add optional start delay to
Timer
by @llucax in #145 - Bump hypothesis from 6.82.2 to 6.82.3 by @dependabot in #148
- Bump mypy from 1.4.1 to 1.5.0 by @dependabot in #149
- Bump hypothesis from 6.82.3 to 6.82.4 by @dependabot in #150
- Bump mypy from 1.5.0 to 1.5.1 by @dependabot in #152
- Bump hypothesis from 6.82.4 to 6.82.5 by @dependabot in #155
- Bump hypothesis from 6.82.5 to 6.82.6 by @dependabot in #157
- Bump mkdocs-material from 9.1.21 to 9.2.1 by @dependabot in #158
- Bump mkdocs-material from 9.2.1 to 9.2.3 by @dependabot in #159
- Update watchfiles requirement from <0.20.0,>=0.15.0 to >=0.15.0,<0.21.0 by @dependabot in #160
- Bump mkdocs-material from 9.2.3 to 9.2.5 by @dependabot in #161
- Bump hypothesis from 6.82.6 to 6.84.0 by @dependabot in #171
- Bump mkdocstrings[python] from 0.22.0 to 0.23.0 by @dependabot in #167
- Bump mkdocs-material from 9.2.5 to 9.2.8 by @dependabot in #172
- Bump hypothesis from 6.84.0 to 6.84.1 by @dependabot in #173
- Bump mkdocs-section-index from 0.3.5 to 0.3.6 by @dependabot in #174
- Bump actions/checkout from 3 to 4 by @dependabot in #170
- Bump pytest from 7.4.0 to 7.4.1 by @dependabot in #169
- Bump hypothesis from 6.84.1 to 6.84.2 by @dependabot in #175
- Replace obsolete types by @daniel-zullo-frequenz in #176
- Upgrade to repo-config v0.5.2 by @llucax in #153
- Bump mkdocs-literate-nav from 0.6.0 to 0.6.1 by @dependabot in #179
- Bump pytest from 7.4.1 to 7.4.2 by @dependabot in #178
- Bump mkdocs-material from 9.2.8 to 9.3.1 by @dependabot in #183
- Bump hypothesis from 6.84.2 to 6.84.3 by @dependabot in #181
- Bump black from 23.7.0 to 23.9.1 by @dependabot in #180
- Bump mkdocs-section-index from 0.3.6 to 0.3.7 by @dependabot in #184
- docs: Improve README and intro by @llucax in #189
- Document class and module attributes by @daniel-zullo-frequenz in #185
- Bump hypothesis from 6.84.3 to 6.86.2 by @dependabot in #192
- Bump mkdocs-material from 9.3.1 to 9.3.2 by @dependabot in #191
- Bump hypothesis from 6.86.2 to 6.87.1 by @dependabot in #200
- Bump pylint from 2.17.5 to 2.17.7 by @dependabot in #201
- Bump hypothesis from 6.87.1 to 6.87.3 by @dependabot in #206
- Make internal variable names private by @shsms in #213
- Bump hypothesis from 6.87.3 to 6.88.0 by @dependabot in #210
- Update watchfiles requirement from <0.21.0,>=0.15.0 to >=0.15.0,<0.22.0 by @dependabot in #211
- Bump mypy from 1.5.1 to 1.6.0 by @dependabot in #208
- Bump mypy from 1.6.0 to 1.6.1 by @dependabot in #216
- Bump pytest from 7.4.2 to 7.4.3 by @dependabot in #220
- Bump hypothesis from 6.88.0 to 6.88.1 by @dependabot in #214
- Bump pytest-mock from 3.11.1 to 3.12.0 by @dependabot in #217
- Bump mkdocs-section-index from 0.3.7 to 0.3.8 by @dependabot in #196
- Bump black from 23.9.1 to 23.10.1 by @dependabot in #219
- Make
resend_latest
a public attribute forBroadcast
channels by @shsms in #221 - Update to repo-config v0.7.1 by @llucax in #223
- 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
- Clear release notes by @llucax in #285
- Bump nox from 2023.4.22 to 2024.3.2 by @dependabot in #287
- Bump the optional group with 11 updates by @dependabot in #286
- Update release notes for the 1.0.0 final release by @llucax in #288
- Bump the optional group with 1 update by @dependabot in #290
Full Changelog: v0.16.1...v1.0.0