-
Notifications
You must be signed in to change notification settings - Fork 95
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
Fix _FakeServer to immediately close client connections #524
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #524 +/- ##
==========================================
- Coverage 97.86% 97.77% -0.10%
==========================================
Files 23 23
Lines 5707 5696 -11
Branches 764 763 -1
==========================================
- Hits 5585 5569 -16
- Misses 76 82 +6
+ Partials 46 45 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
To maintainers, I'm happy to provide more information on what this does, or make any changes needed. |
Looks like we had a codecov issue; probably due to no longer skipping the one test 🤔 Or perhaps the added code isn't being hit. I'm guessing this is actually the right way to fix this but it's been a while since I've been in the codebase 🙂 |
Without this, if the SMTP server throws an exception during initialization, Controller.stop() gets stuck indefinitely waiting on active connections. Note: this only happens in Python 3.12+. Earlier versions of Python allowed `wait_closed()` to complete regardless of active connections. With this change the TestFactory testcases can again be enabled for Python 3.12+. Fixes: aio-libs#394
f4782b0
to
06740c4
Compare
I ran tests like so on my local system:
When running it on the master branch, it prints the following coverage report:
On the PR branch it prints:
The coverage increased--which makes sense as the PR re-enables some previously disabled tests. I'm not familiar with aiosmtpd build and CI infrastructure, and am not sure why codecov reports different results. Perhaps it's using code coverage from a test run with a different python interpreter version? (my local system has Python 3.12) |
I thought I found unused code ( |
That's super weird. I'm not familiar with codecov either -- I'm a wee bit confused looking at the coverage report. https://app.codecov.io/gh/aio-libs/aiosmtpd/pull/524/indirect-changes seems to suggest that there are some inderect changes as a result of this PR. If you run with |
FWIW these indirect coverage changes are not due to code changes in this PR. There are similar coverage changes in previous PRs that did get merged, for example: https://app.codecov.io/gh/aio-libs/aiosmtpd/pull/540/indirect-changes |
What do these changes do?
This implements
_FakeServer.connection_made()
which immediately closes client connections.Without this, if the SMTP server throws an exception during initialization, Controller.stop() gets stuck indefinitely waiting on active connections.
Note: this only happens in Python 3.12+. Earlier versions of Python allowed
wait_closed()
to complete regardless of active connections.With this change the TestFactory testcases can again be enabled for Python 3.12+.
Are there changes in behavior for the user?
No change for the happy path, as _FakeServer is only used if the SMTP server throws exception during initialization.
Related issue number
Fixes: #394
Checklist
{py312}
{py36,py37,py38,py39}-{nocov,cov,diffcov}
{py36,py37,py38,py39}-{nocov,cov,diffcov}, pypy3-{nocov,cov}, qa, docs
{py36,pypy3}-{nocov,cov,diffcov}, qa
py36-{nocov,cov,diffcov}, qa, docs
NEWS.rst
file