From: Antoine Pitrou Date: Sun, 22 Oct 2017 14:02:14 +0000 (+0200) Subject: Don't keep any reference to memoryviews (#2173) X-Git-Tag: v5.0.0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa3409179588536f2f743d16e537f6f9827fa92f;p=thirdparty%2Ftornado.git Don't keep any reference to memoryviews (#2173) See https://github.com/tornadoweb/tornado/pull/2008 for reasons why this might be necessary. --- diff --git a/tornado/iostream.py b/tornado/iostream.py index 632952b52..2026ae57e 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -1066,7 +1066,12 @@ class IOStream(BaseIOStream): return chunk def write_to_fd(self, data): - return self.socket.send(data) + try: + return self.socket.send(data) + finally: + # Avoid keeping to data, which can be a memoryview. + # See https://github.com/tornadoweb/tornado/pull/2008 + del data def connect(self, address, callback=None, server_hostname=None): """Connects the socket to a remote address without blocking. @@ -1475,6 +1480,10 @@ class SSLIOStream(IOStream): # simply return 0 bytes written. return 0 raise + finally: + # Avoid keeping to data, which can be a memoryview. + # See https://github.com/tornadoweb/tornado/pull/2008 + del data def read_from_fd(self): if self._ssl_accepting: @@ -1532,7 +1541,12 @@ class PipeIOStream(BaseIOStream): os.close(self.fd) def write_to_fd(self, data): - return os.write(self.fd, data) + try: + return os.write(self.fd, data) + finally: + # Avoid keeping to data, which can be a memoryview. + # See https://github.com/tornadoweb/tornado/pull/2008 + del data def read_from_fd(self): try: