]> granicus.if.org Git - python/commitdiff
bpo-30199: test_ssl closes all asyncore channels (#1381) (#1390)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 2 May 2017 14:49:10 +0000 (16:49 +0200)
committerGitHub <noreply@github.com>
Tue, 2 May 2017 14:49:10 +0000 (16:49 +0200)
AsyncoreEchoServer of test_ssl now calls
asyncore.close_all(ignore_all=True) to ensure that
asyncore.socket_map is cleared once the test completes, even if
ConnectionHandler was not correctly unregistered.

Fix the following warning:

Warning -- asyncore.socket_map was modified by test_ssl
  Before: {}
  After:  {6: <test.test_ssl.AsyncoreEchoServer.EchoServer.ConnectionHandler>}
(cherry picked from commit 1dae7450c68bad498e57800387b24cb103c461fa)

Lib/test/test_ssl.py

index d203cddbdfb5eefddab2870973ad12b093d90cd4..85c59a618ce1e9949f7f323dc430b709f374ee17 100644 (file)
@@ -2065,7 +2065,7 @@ if _have_threads:
 
         class EchoServer (asyncore.dispatcher):
 
-            class ConnectionHandler (asyncore.dispatcher_with_send):
+            class ConnectionHandler(asyncore.dispatcher_with_send):
 
                 def __init__(self, conn, certfile):
                     self.socket = test_wrap_socket(conn, server_side=True,
@@ -2156,6 +2156,8 @@ if _have_threads:
             self.join()
             if support.verbose:
                 sys.stdout.write(" cleanup: successfully joined.\n")
+            # make sure that ConnectionHandler is removed from socket_map
+            asyncore.close_all(ignore_all=True)
 
         def start (self, flag=None):
             self.flag = flag