Skip to content

DE-819 | bring back REQUEST_TIMEOUT as a class attribute #344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion arango/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ class DefaultHTTPClient(HTTPClient):
:type pool_timeout: int | float | None
"""

REQUEST_TIMEOUT = DEFAULT_REQUEST_TIMEOUT

def __init__(
self,
request_timeout: Union[int, float, None] = DEFAULT_REQUEST_TIMEOUT,
request_timeout: Union[int, float, None] = REQUEST_TIMEOUT,
retry_attempts: int = 3,
backoff_factor: float = 1.0,
pool_connections: int = 10,
Expand Down
25 changes: 25 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,31 @@ def test_client_http_client_attributes(db, username, password):
assert http_client.request_timeout == 80
assert client.request_timeout == http_client.request_timeout

client_no_timeout = ArangoClient(
hosts="http://127.0.0.1:8529", request_timeout=None
)

assert client_no_timeout.request_timeout is None

client_no_timeout = ArangoClient(
hosts="http://127.0.0.1:8529",
http_client=DefaultHTTPClient(request_timeout=None),
)

assert client_no_timeout.request_timeout is None

class NoTimeoutHTTPClient(DefaultHTTPClient):
REQUEST_TIMEOUT = None

def __init__(self, *args, **kwargs):
super().__init__(request_timeout=self.REQUEST_TIMEOUT, *args, **kwargs)
Comment on lines +126 to +130
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously, the NoTimeoutHTTPClient with a class REQUEST_TIMEOUT would work without needing an __init__. This is PR basically introduces the ability to support REQUEST_TIMEOUT again, but with the exception of needing an __init__


client_no_timeout = ArangoClient(
hosts="http://127.0.0.1:8529", http_client=NoTimeoutHTTPClient()
)

assert client_no_timeout.request_timeout is None


def test_client_custom_http_client(db, username, password):
# Define custom HTTP client which increments the counter on any API call.
Expand Down
Loading