[ python-Bugs-1462352 ] socket.ssl won't work together with socket.settimeout on Win
SourceForge.net
noreply at sourceforge.net
Sun Apr 2 04:08:07 CEST 2006
Bugs item #1462352, was opened at 2006-03-31 14:11
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1462352&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Windows
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: Georg Brandl (gbrandl)
Assigned to: Nobody/Anonymous (nobody)
Summary: socket.ssl won't work together with socket.settimeout on Win
Initial Comment:
Symptoms:
>>> import socket
>>> s = socket.socket()
>>> s.settimeout(30.0)
>>> s.connect(("gmail.org", 995))
>>> ss = socket.ssl(s)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\python24\lib\socket.py", line 74, in ssl
return _realssl(sock, keyfile, certfile)
socket.sslerror: (2, 'The operation did not complete
(read)')
This does not occur on Unix, where
test_socket_ssl.test_timeout runs smoothly.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2006-04-01 21:08
Message:
Logged In: YES
user_id=31435
BTW, does anyone understand why this part of my first
comment was true?:
"""
check_socket_and_wait_for_timeout() takes the "else if
(s->sock_timeout == 0.0)" path and and returns
SOCKET_IS_NONBLOCKING.
"""
How did s->sock_timeout become 0? s.settimeout(30.0) was
called, and the same s was passed to socket.ssl(). I don't
understand this at all:
>>> s.connect(("gmail.org", 995))
>>> s.gettimeout()
30.0
>>> s._sock
<socket object, fd=1920, family=2, type=1, protocol=0>
>>> s._sock.gettimeout()
30.0
>>> ss = socket.ssl(s)
but a breakpoint in newPySSLObject() right there shows that
Sock->sock_timeout is 0.0. HTF did that happen?
If I poke 30.0 (under the debugger) into Sock->sock_timeout
at the start of newPySSLObject(), the constructor finishes
unexceptionally.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2006-04-01 20:57
Message:
Logged In: YES
user_id=31435
gmail.com happened to respond when I tried it today, so I
can confirm (alas) that the patch at
http://pastebin.com/633224
made no difference to the outcome on Windows.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2006-03-31 20:36
Message:
Logged In: YES
user_id=31435
Because the
s.connect(("gmail.org", 995))
line started timing out on all (non-Windows) buildbot slaves
some hours ago, causing all test runs to fail, I disabled
test_timeout on all boxes for now (on trunk & on 2.4 branch).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2006-03-31 18:23
Message:
Logged In: YES
user_id=31435
Note that this is a problem in 2.4 and trunk.
The sample code worked fine earlier today if (and only if) I
left out the .settimeout() call.
Note that buildbot test runs are failing in trunk and 2.4
branch now on non-Windows boxes, because the
s.connect(("gmail.org", 995))
line is timing out (the new test is disabled on Windows, and
that's why the Windows buildbots are still passing). At the
moment, that's timing out on my Windows box too. We clearly
need a more reliable net address to connect to.
On Bug Day IRC, "arekm" last asked that I try this patch on
Windows:
http://pastebin.com/633224
Unfortunately, I haven't been able to get beyond the
s.connect(("gmail.org", 995)) line since then, so still
don't know whether that helps. Nothing else did ;-)
On Windows, in newPySSLObject(),
"ret = SSL_connect(self->ssl);" returns -1
"err = SSL_get_error(self->ssl, ret);" returns 2
"if (err == SSL_ERROR_WANT_READ)" triggers.
check_socket_and_wait_for_timeout() takes the "else if
(s->sock_timeout == 0.0)" path and and returns
SOCKET_IS_NONBLOCKING.
newPySSLObject() breaks out of its loop then, and does
"PySSL_SetError(self, ret); goto fail;"
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1462352&group_id=5470
More information about the Python-bugs-list
mailing list