I am using tavern
to test python flask application. Occasionally, I got http connection errors like:
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket.socket(af, socktype, proto)
# If provided, set socket level options before connecting.
_set_socket_options(sock, socket_options)
if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
> sock.connect(sa)
E **ConnectionRefusedError: [Errno 111] Connection refused**
One possible reason is that the connection is timed out so I'd like to change the timeout for http connection used by tavern
. I can't find a configuration from tavern
for changing this value but based on the source code above, it seems that the default timeout is read from socket._GLOBAL_DEFAULT_TIMEOUT
. How can I change this value from my app? I don't call this connection method directly which is called by Tavern
framework. Is there a way to update it from my app side?
I am using pytest
to run the test so it is also good if I can set something on pytest
to override this value.