-
Notifications
You must be signed in to change notification settings - Fork 101
Python 3.14 compatibility + EZSP-over-TCP stability fixes #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
silenthooligan
wants to merge
6
commits into
zigpy:dev
Choose a base branch
from
silenthooligan:fix/python-3.14-ezsp-tcp
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2374548
Python 3.14 compatibility + EZSP-over-TCP stability fixes
silenthooligan 3f34b5c
tests: cover new EZSP disconnect + ThreadsafeProxy mid-dispatch paths
silenthooligan 7cf20c0
fix: drop transport.get_extra_info socket force-close per #720 review
silenthooligan 3ad85ef
fix: pre-create _startup_reset_future inside Gateway per #720 review
silenthooligan f43c38f
revert: drop ash.py eof_received -> True per #720 review
silenthooligan 384975d
style: use contextlib.suppress in EZSP.disconnect per ruff SIM105
silenthooligan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,8 +52,8 @@ def error_received(self, code: t.NcpResetCode) -> None: | |
|
|
||
| async def wait_for_startup_reset(self) -> None: | ||
| """Wait for the first reset frame on startup.""" | ||
| assert self._startup_reset_future is None | ||
| self._startup_reset_future = asyncio.get_running_loop().create_future() | ||
| if self._startup_reset_future is None: | ||
| self._startup_reset_future = asyncio.get_running_loop().create_future() | ||
|
|
||
| try: | ||
| await self._startup_reset_future | ||
|
|
@@ -98,21 +98,26 @@ async def reset(self): | |
| return await self._reset_future | ||
|
|
||
| self._transport.send_reset() | ||
| self._reset_future = asyncio.get_event_loop().create_future() | ||
| self._reset_future = asyncio.get_running_loop().create_future() | ||
| self._reset_future.add_done_callback(self._reset_cleanup) | ||
|
|
||
| async with asyncio_timeout(RESET_TIMEOUT): | ||
| return await self._reset_future | ||
|
|
||
|
|
||
| async def _connect(config, api): | ||
| loop = asyncio.get_event_loop() | ||
| loop = asyncio.get_running_loop() | ||
|
|
||
| connection_done_future = loop.create_future() | ||
|
|
||
| gateway = Gateway(api, connection_done_future) | ||
| protocol = AshProtocol(gateway) | ||
|
|
||
| # Pre-create the startup reset future before opening the connection so that | ||
| # reset frames arriving immediately after connect are captured by | ||
| # reset_received() instead of triggering enter_failed_state(). | ||
| gateway._startup_reset_future = loop.create_future() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be simpler to have |
||
|
|
||
| if config[zigpy.config.CONF_DEVICE_FLOW_CONTROL] is None: | ||
| xon_xoff, rtscts = True, False | ||
| else: | ||
|
|
@@ -135,7 +140,7 @@ async def _connect(config, api): | |
|
|
||
| async def connect(config, api, use_thread=True): | ||
| if use_thread: | ||
| api = ThreadsafeProxy(api, asyncio.get_event_loop()) | ||
| api = ThreadsafeProxy(api, asyncio.get_running_loop()) | ||
| thread = EventLoopThread() | ||
| await thread.start() | ||
| try: | ||
|
|
||
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the remote signal EOF without closing? The asyncio docs state machine shows:
And the docs state:
I don't think this change is right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I borrowed that hunk from #711's commit body (the closed-unmerged PR by @aautem this one rebased from) without validating its premise myself, it claimed an init-time spurious EOF on serial-over-TCP. You're right that the asyncio docs are clear, and honestly I don't have a reproduction of that scenario on my own setup either: stock 0.49.1 on Python 3.14.2 against the ZBT-2 over
stream_servercompletes EZSP startup cleanly on first connect (log in the gist as01-stock-probe.log).Dropping it and deferring to you on this one. You know this code far better than I do, and I'd rather get it right than push something speculative. Door's open if a concrete EOF-during-init case surfaces later for some bridge config.
Reverted in
f43c38f.