bpd plugin: use asyncio directly and remove bluelet - #6903
Open
snejus wants to merge 2 commits into
Open
Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
snejus
force-pushed
the
refactor-bluelet
branch
from
August 4, 2026 00:09
1a5d8ae to
cf209d0
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR move bpd plugin off custom Bluelet scheduler and onto stdlib asyncio. this remove homegrown async engine and make server code speak native async/await.
Changes:
- rewrite
beetsplug.bpdserver + connection flow toasyncio.start_serverand stream reader/writer - remove
beets.util.blueletmodule - update BPD tests + changelog for new server entrypoint and behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
beetsplug/bpd/__init__.py |
replace Bluelet generator scheduler with asyncio servers/tasks; refactor connection I/O to streams |
beets/util/bluelet.py |
delete Bluelet implementation (no longer used) |
test/plugins/test_bpd.py |
mock asyncio.start_server instead of Bluelet listener for dynamic port assignment test |
docs/changelog.rst |
add unreleased changelog entry noting BPD move to asyncio |
Comment on lines
+269
to
+272
| for conn in list(self.connections): | ||
| yield bluelet.spawn(conn.send_notifications()) | ||
| task = asyncio.create_task(conn.send_notifications()) | ||
| self._notification_tasks.add(task) | ||
| task.add_done_callback(self._notification_tasks.discard) |
Comment on lines
869
to
873
| err = BPDError( | ||
| ERROR_UNKNOWN, f"Got command while idle: {line}" | ||
| ) | ||
| yield self.send(err.response()) | ||
| await self.send(err.response()) | ||
| break |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6903 +/- ##
==========================================
+ Coverage 75.69% 75.87% +0.17%
==========================================
Files 163 162 -1
Lines 21412 21107 -305
Branches 3384 3336 -48
==========================================
- Hits 16208 16015 -193
+ Misses 4405 4309 -96
+ Partials 799 783 -16
🚀 New features to boost your workflow:
|
snejus
force-pushed
the
refactor-bluelet
branch
from
August 4, 2026 00:34
cf209d0 to
d67a23d
Compare
- Track active notification tasks by connection so repeated dispatches do not send duplicate idle responses while a previous send is still draining. - Add regression coverage for serialized notification delivery and idle command disconnect handling.
snejus
force-pushed
the
refactor-bluelet
branch
from
August 5, 2026 01:08
d67a23d to
35579c4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So I was looking to add types to
beets.util.blueletand realised that it is only used byBPDplugin. Instead of investing any time into it, I scrapped it and usedasynciodirectly inBPD. I used GitHub search to check that it is not used outside of our codebase.Replaces the custom coroutine scheduler in
beets.util.blueletwith Python's built-inasynciofor thebpdplugin.In
beetsplug/bpd/__init__.py, the server architecture shifts from Bluelet generators and event objects to native async I/O:asyncio.start_serverasync defmethods withawaitasynciotasksasynciostream readers/writersThis removes an internal async framework from the codebase, consolidates
bpdon a standard runtime model, and makes the networking layer simpler to reason about and maintain.Tests in
test/plugins/test_bpd.pyare updated to mockasyncio.start_serverinstead of Bluelet internals, matching the new server entrypoint and preserving coverage around dynamic port assignment.