-
Notifications
You must be signed in to change notification settings - Fork 96
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
Some tests in aiosmtpd/tests/test_server.py hang with python 3.12 #394
Comments
I think I figured out what is going wrong here.
While closing the controller, the execution gets stuck waiting on self.server.wait_closed() here. Looking at wait_closed() source I think we can see why this used to work in 3.11 but does not work in 3.12 any more:
The active connection is the one made by If an exception is thrown during SMTP server initialization, an instance of As an experiment, I added the following to _FakeServer: def connection_made(self, transport):
transport.close() The idea was to unconditionally close client connections right after they've been opened. I'm new to all of this, so perhaps this is not the right way to do it. But it seems to work, with this in place the PS. This is not just a test environment problem, the hanging also happens in normal code. Here's an isolated example (run with py 3.12+): from aiosmtpd.controller import Controller
from aiosmtpd.handlers import Sink
controller = Controller(Sink(), a=1)
try:
controller.start()
except Exception as e:
pass
print("This next line will block indefinitely:")
controller.stop() |
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
This is on debian/trixie, using aiosmtpd 1.4.4.post2-1 or 1.4.3.
It hangs even when there is an actual online network (it also hangs in a restricted container).
This one for example:
Works with python3.11
Maybe it's because some plugin is not up-to-date ?
I played with it a little and any clue might unblock the situation.
The text was updated successfully, but these errors were encountered: