mavtcp: mark closed sockets as disconnected without autoreconnect#1193
Open
vvezre wants to merge 1 commit intoArduPilot:masterfrom
Open
mavtcp: mark closed sockets as disconnected without autoreconnect#1193vvezre wants to merge 1 commit intoArduPilot:masterfrom
vvezre wants to merge 1 commit intoArduPilot:masterfrom
Conversation
peterbarker
requested changes
Apr 1, 2026
|
|
||
| def close(self): | ||
| self.port.close() | ||
| if self.port is not None: |
Contributor
There was a problem hiding this comment.
Why is this guard needed now?
Comment on lines
+9
to
+24
| try: | ||
| from pymavlink import mavutil | ||
| except ModuleNotFoundError: | ||
| repo_root = Path(__file__).resolve().parents[1] | ||
| pkg_spec = importlib.util.spec_from_file_location( | ||
| "pymavlink", | ||
| repo_root / "__init__.py", | ||
| submodule_search_locations=[str(repo_root)], | ||
| ) | ||
| assert pkg_spec is not None and pkg_spec.loader is not None | ||
| pymavlink_pkg = importlib.util.module_from_spec(pkg_spec) | ||
| sys.modules["pymavlink"] = pymavlink_pkg | ||
| pkg_spec.loader.exec_module(pymavlink_pkg) | ||
| from pymavlink import mavutil | ||
|
|
||
|
|
Contributor
There was a problem hiding this comment.
Please simplify to import like the other tests.
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.
Summary
autoreconnect=Falsemavtcp.recv()raiseConnectionErrorif no socket is available after reconnect logicautoreconnect=TrueECONNRESETdisconnect handlingWhy
mavtcpcurrently leavesself.portset after disconnect events when auto-reconnect is disabled.That makes disconnect detection difficult and can cause repeated EOF handling without a stable disconnected state.
Testing
python -m pytest C:\Users\woshe\Documents\Playground\pymavlink-git\tests\test_mavtcp.py -qpython -m py_compile C:\Users\woshe\Documents\Playground\pymavlink-git\mavutil.py C:\Users\woshe\Documents\Playground\pymavlink-git\tests\test_mavtcp.pyCloses #742