-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
tests/extmod: Close UDP timely. #17660
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17660 +/- ##
=======================================
Coverage 98.44% 98.44%
=======================================
Files 171 171
Lines 22192 22192
=======================================
Hits 21847 21847
Misses 345 345 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Thanks for the contribution. This is a good fix. But I think the socket also needs to be closed in the initial detection part of the script at the top. This bit of code: try:
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(socket.getaddrinfo("127.0.0.1", 8000)[0][-1])
except OSError:
print("SKIP")
raise SystemExit should probably be changed to: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.bind(socket.getaddrinfo("127.0.0.1", 8000)[0][-1])
except OSError:
s.close()
print("SKIP")
raise SystemExit |
@dpgeorge thanks for the comment. But I have some concerns regarding this close-before-SKIP:
So do we really want that? |
Correct. The
Correct, it will eventually be closed by the GC (most likely on soft reset). Usually we like to make the tests clean up properly after themselves. You are right that it may help reveal more issues, although there should be other tests for that.
Yes there are a few other tests where this pattern appears, and would need to be fixed for consistency. If you want to keep this PR small and of limited scope, then I'm happy for it to stay as-is, just closing the socket at the end of the test. At least that helps with the situation you identified, running the tests in parallel. |
@dpgeorge, thank you for the confirmations. as I am too new to the code base, it is better to stick with small changes fow now. We can do more cleanups later in separate PR, how do you think? |
Yes, I'm always happy to have smaller changes. |
This adds call to release UDP port in a timely manner, so they can be reused in subsequent tests. Otherwise, one could face issue like micropython#17623. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
Summary
This adds call to release UDP port timely so that to reuse it in other tests. Otherwise, one could face issue like https://github.com/orgs/micropython/discussions/17623.
Testing
Tested with VARIANT coverage of UNIX port on Ubuntu 22.04.