Skip to content

Commit 6d59b9d

Browse files
committed
Fix _FakeServer to immediately close 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+. Fixes: #394
1 parent 9ecdc36 commit 6d59b9d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

aiosmtpd/controller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def _cb_client_connected(
108108
) -> None:
109109
pass
110110

111+
def connection_made(self, transport):
112+
transport.close()
113+
111114

112115
@public
113116
class BaseController(metaclass=ABCMeta):

aiosmtpd/tests/test_server.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ def test_inet_contstop(self, temp_event_loop, runner):
535535
assert temp_event_loop.is_closed() is False
536536

537537

538-
@pytest.mark.skipif(sys.version_info >= (3, 12), reason="Hangs on 3.12")
539538
@pytest.mark.filterwarnings("ignore::pytest.PytestUnraisableExceptionWarning")
540539
class TestFactory:
541540
def test_normal_situation(self):

0 commit comments

Comments
 (0)