[Python-Dev] the new 2.3a1 settimeout() with httplib and SSL

Geoffrey Talvola gtalvola@nameconnector.com
Fri, 24 Jan 2003 18:37:38 -0500


I'm trying to get the new socket.settimeout() in Python 2.3a1 to work in
conjunction with httplib and SSL.  This code seems to work fine:

	import httplib
	conn = httplib.HTTPConnection('ncsdevtest.nameconnector.com', 80)
	conn.connect()
	conn.sock.settimeout(90)
	conn.request('GET', '/cgi-bin/Pause30.cgi')
	response = conn.getresponse()
	print response.status, response.reason
	data = response.read()
	print 'read', len(data), 'bytes'
	conn.close()

Where Pause30.cgi is a cgi script that simply sleeps for 30 seconds then
sends back a simple response.

As-is, this program returns after 30 seconds.  If I adjust the timeout of 90
to be, lets say, 5 seconds, I correctly get a timeout exception after 5
seconds.  So far, so good.

But if I change HTTPConnection to HTTPSConnection and change 80 to 443, I
have trouble -- my CPU usage goes up to 100%, the python process sucks up
more and more memory, and it doesn't time out at all.  It does still returns
the correct response after 30 seconds.

Is there a way to do this?  Should I enter a bug report?

- Geoff