Skip to content

Commit

Permalink
bpo-30199: test_ssl closes all asyncore channels (#1381)
Browse files Browse the repository at this point in the history
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>}
  • Loading branch information
vstinner committed May 2, 2017
1 parent 92fd6c9 commit 1dae745
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Lib/test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,7 @@ class AsyncoreEchoServer(threading.Thread):

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,
Expand Down Expand Up @@ -2155,6 +2155,8 @@ def __exit__(self, *args):
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
Expand Down

0 comments on commit 1dae745

Please sign in to comment.