aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 6179e28759c..bb31e29ca76 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -829,6 +829,7 @@ class TestSMTPServer(smtpd.SMTPServer):
self.port = self.socket.getsockname()[1]
self._handler = handler
self._thread = None
+ self._quit = False
self.poll_interval = poll_interval
def process_message(self, peer, mailfrom, rcpttos, data):
@@ -860,16 +861,18 @@ class TestSMTPServer(smtpd.SMTPServer):
:func:`select` or :func:`poll` call by
:func:`asyncore.loop`.
"""
- asyncore.loop(poll_interval, map=self._map)
+ while not self._quit:
+ asyncore.loop(poll_interval, map=self._map, count=1)
def stop(self):
"""
Stop the thread by closing the server instance.
Wait for the server thread to terminate.
"""
- self.close()
+ self._quit = True
threading_helper.join_thread(self._thread)
self._thread = None
+ self.close()
asyncore.close_all(map=self._map, ignore_all=True)