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

Simon Josefsson simon at josefsson.org
Mon Mar 9 22:13:31 CET 2009


Stephane Bortzmeyer <bortzmeyer at nic.fr> writes:

> 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>
>     session.handshake()
>   File "/var/lib/python-support/python2.5/gnutls/connection.py", line 370, in handshake
>     gnutls_handshake(self._c_object)
>   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.

I suspect this means one of two things:

1) The timeout was reached.

2) The socket is in non-blocking mode, and then you need to call the
gnutls_handshake function repeatedly until it either returns
successfully, or fails, or the timeout is reached.  I dont know whether
the python-gnutls wrapper is expected to do this or whether your python
application code is expected to do it.

/Simon





More information about the Gnutls-help mailing list