]> granicus.if.org Git - python/commitdiff
bpo-30199: test_ssl closes all asyncore channels (#1381) (#1389)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 2 May 2017 14:48:36 +0000 (16:48 +0200)
committerGitHub <noreply@github.com>
Tue, 2 May 2017 14:48:36 +0000 (16:48 +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 551558304fcdd62419322e1d21a7a61e634a8d3d..ffb7314f577c19e7b0a857b4f3a167a34151aca5 100644 (file)
@@ -2034,7 +2034,7 @@ else:
 
         class EchoServer (asyncore.dispatcher):
 
-            class ConnectionHandler (asyncore.dispatcher_with_send):
+            class ConnectionHandler(asyncore.dispatcher_with_send):
 
                 def __init__(self, conn, certfile):
                     self.socket = ssl.wrap_socket(conn, server_side=True,
@@ -2125,6 +2125,8 @@ else:
             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