Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cuu508
Copy link
Contributor

@cuu508 cuu508 commented Oct 28, 2024

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

  • I think the code is well written
  • Unit tests for the changes exist
  • tox testenvs have been executed in the following environments:
    • Linux (Ubuntu 24.04): {py312}
    • Windows (7, 10): {py36,py37,py38,py39}-{nocov,cov,diffcov}
    • WSL 1.0 (Ubuntu 18.04): {py36,py37,py38,py39}-{nocov,cov,diffcov}, pypy3-{nocov,cov}, qa, docs
    • FreeBSD (12.2, 12.1, 11.4): {py36,pypy3}-{nocov,cov,diffcov}, qa
    • Cygwin: py36-{nocov,cov,diffcov}, qa, docs
  • Documentation reflects the changes
  • Add a news fragment into the NEWS.rst file

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
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (f40ac96) to head (6d59b9d).
Report is 38 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #524      +/-   ##
==========================================
- Coverage   97.86%   97.75%   -0.11%     
==========================================
  Files          23       23              
  Lines        5707     5698       -9     
  Branches      764      763       -1     
==========================================
- Hits         5585     5570      -15     
- Misses         76       83       +7     
+ Partials       46       45       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some tests in aiosmtpd/tests/test_server.py hang with python 3.12
1 participant