mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
Make timeout optional, enable it only for integration tests.
This commit is contained in:
parent
ebed5100b9
commit
f9a1eedaea
@ -4,6 +4,7 @@ Ported to Python 3.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
from time import sleep
|
||||
@ -49,6 +50,11 @@ from .util import (
|
||||
)
|
||||
|
||||
|
||||
# No reason for HTTP requests to take longer than two minutes in the
|
||||
# integration tests. See allmydata/scripts/common_http.py for usage.
|
||||
os.environ["__TAHOE_CLI_HTTP_TIMEOUT"] = "120"
|
||||
|
||||
|
||||
# pytest customization hooks
|
||||
|
||||
def pytest_addoption(parser):
|
||||
|
@ -1 +0,0 @@
|
||||
The command-line tools now have a 300-second timeout on individual network reads/writes/connects; previously they could block forever in some situations.
|
0
newsfragments/4012.minor
Normal file
0
newsfragments/4012.minor
Normal file
@ -53,10 +53,17 @@ def do_http(method, url, body=b""):
|
||||
assert body.seek
|
||||
assert body.read
|
||||
scheme, host, port, path = parse_url(url)
|
||||
|
||||
# For testing purposes, allow setting a timeout on HTTP requests. If this
|
||||
# ever become a user-facing feature, this should probably be a CLI option?
|
||||
timeout = os.environ.get("__TAHOE_CLI_HTTP_TIMEOUT", None)
|
||||
if timeout is not None:
|
||||
timeout = float(timeout)
|
||||
|
||||
if scheme == "http":
|
||||
c = http_client.HTTPConnection(host, port, timeout=300, blocksize=65536)
|
||||
c = http_client.HTTPConnection(host, port, timeout=timeout, blocksize=65536)
|
||||
elif scheme == "https":
|
||||
c = http_client.HTTPSConnection(host, port, timeout=300, blocksize=65536)
|
||||
c = http_client.HTTPSConnection(host, port, timeout=timeout, blocksize=65536)
|
||||
else:
|
||||
raise ValueError("unknown scheme '%s', need http or https" % scheme)
|
||||
c.putrequest(method, path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user