Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix mavutil.mavtcpin not closing the accept()ed port on close() #760

Merged
merged 1 commit into from
Dec 28, 2022

Conversation

maranov
Copy link

@maranov maranov commented Dec 15, 2022

Hi, mavutil.mavtcpin may leave the accept()ed port open after closing, leading to ResourceWarnings like this one:

<frozen importlib._bootstrap>:241: ResourceWarning: unclosed <socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 24550)>
Object allocated at (most recent call last):
  ...
  File "/host/MY_MODULE", lineno 339
    mavlink_msg = self._mavlink.recv_match(
  File "/usr/local/lib/python3.10/site-packages/pymavlink/mavutil.py", lineno 502
    m = self.recv_msg()
  File "/usr/local/lib/python3.10/site-packages/pymavlink/mavutil.py", lineno 459
    s = self.recv(n)
  File "/usr/local/lib/python3.10/site-packages/pymavlink/mavutil.py", lineno 1317
    (self.port, addr) = self.listen.accept()
  File "/usr/local/lib/python3.10/socket.py", lineno 294
    sock = socket(self.family, self.type, self.proto, fileno=fd)

pymavlink 2.4.37 on both Windows and Linux (x86_64) and Python 3.10.

This MR fixes it. Also there's an unrelated set_close_on_exec docstring typo fix.

@maranov maranov force-pushed the bugfix/mavtcpin-socket-close branch from 303820e to 33e2936 Compare December 16, 2022 08:24
@tridge tridge merged commit 8fa1865 into ArduPilot:master Dec 28, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants