Here is the workaround I'm using until the code gets fixed:
import ssl
# Work around python bug #5328
def SSLSocket_makefile_fixed(self, mode='r', bufsize=-1):
from socket import _fileobject
self._makefile_refs += 1
return _fileobject(self, mode, bufsize, True)
ssl.SSLSocket.makefile = SSLSocket_makefile_fixed
An alternate way to fix it is to reach in to the _fileobject wrapper and close the underlying
implementation:
In the do_GET() method of my web server I called:
self.rfile._sock.close()
self.wfile._sock.close()
-Costa
Jonathan Hayward <jonathan.hayward@pobox.com> added the comment:
Is there a workaround to close a TLS socket and its underlying socket?
I was making something to use https for a simple operation, and it the
browser acted as if the socket never closed. If I followed the close of
the ssl socket by a close of the underlying socket, I didn't get errors,
but the browser throbber acted as if the connection was still open.
Jonathan, http://JonathansCorner.com/
----------
nosy: +JonathansCorner.com
_______________________________________
Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue5238>
_______________________________________