From: Antoine Pitrou Date: Sun, 11 Jun 2017 08:41:45 +0000 (+0200) Subject: Use getitem / setitem idiom on nonlocal list X-Git-Tag: v5.0.0~67^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b6d0e0673765f3c4bbc437d1599d7b7fd01f53e;p=thirdparty%2Ftornado.git Use getitem / setitem idiom on nonlocal list --- diff --git a/tornado/netutil.py b/tornado/netutil.py index 04a3a4bf4..e58db35df 100644 --- a/tornado/netutil.py +++ b/tornado/netutil.py @@ -251,7 +251,7 @@ def add_accept_handler(sock, callback): A callable is returned (``None`` was returned before). """ io_loop = IOLoop.current() - removed = [] + removed = [False] def accept_handler(fd, events): # More connections may come in while we're handling callbacks; @@ -266,7 +266,7 @@ def add_accept_handler(sock, callback): # heuristic for the number of connections we can reasonably # accept at once. for i in xrange(_DEFAULT_BACKLOG): - if removed: + if removed[0]: # The socket was probably closed return try: @@ -287,7 +287,7 @@ def add_accept_handler(sock, callback): def remove_handler(): io_loop.remove_handler(sock) - removed.append(True) + removed[0] = True io_loop.add_handler(sock, accept_handler, IOLoop.READ) return remove_handler