[Help-gnutls] [Python] Set a timeout on the connection?

Stephane Bortzmeyer bortzmeyer at nic.fr
Mon Mar 9 15:22:51 CET 2009

I use python-gnutls <http://pypi.python.org/pypi/python-gnutls> and it
does not seem to have a dedicated mailing list, so I try here.

The atatched code test1.py runs fine but a small modification, adding
a timeout to the socket (test-timeout.py) crashes with:

Traceback (most recent call last):
  File "test-timeout.py", line 20, in <module>
  File "/var/lib/python-support/python2.5/gnutls/connection.py", line 370, in handshake
  File "/var/lib/python-support/python2.5/gnutls/library/errors.py", line 44, in _check_status
    raise OperationWouldBlock(gnutls_strerror(retcode))
gnutls.errors.OperationWouldBlock: Function was interrupted.

[Side note: I want to connect to TLS servers and ultimately retrieve
info like the issuer of the certificate, things like that. Much more
HTTP servers times out with TLS than without so it is absolutely
necessary to set a maximum time to wait. The project is DNSwitness
<http://www.dnswitness.net/>, end of advertisment. It needs to run
with Python 2.5 so the new SSL module
<http://docs.python.org/library/ssl.html> does not suit me. I gladly
accept suggestions to use another module, if there is a better one,
but I do not want just a TLS connection, I need to be able to access
information about the server certificate.]

More information about the Gnutls-help mailing list