This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author csapuntz
Recipients JonathansCorner.com, csapuntz, dugan, janssen
Date 2009-05-08.20:30:09
SpamBayes Score 9.49018e-09
Marked as misclassified No
Message-id <ea59786f0905081330x47989ff4n1271c69f57205fcd@mail.gmail.com>
In-reply-to <1241812284.05.0.0356155304298.issue5238@psf.upfronthosting.co.za>
Content
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

On Fri, May 8, 2009 at 12:51 PM, Jonathan Hayward <report@bugs.python.org>wrote:

>
> 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>
> _______________________________________
>
Files
File name Uploaded
unnamed csapuntz, 2009-05-08.20:30:07
History
Date User Action Args
2009-05-08 20:30:10csapuntzsetrecipients: + csapuntz, janssen, dugan
2009-05-08 20:30:09csapuntzlinkissue5238 messages
2009-05-08 20:30:09csapuntzcreate