Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class RESTClientObject:

post_params = post_params or {}
headers = {{httpxModule}}.Headers(headers or {})
timeout = _request_timeout or 5 * 60
timeout = _request_timeout or {{httpxModule}}.USE_CLIENT_DEFAULT

if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
Expand Down Expand Up @@ -187,6 +187,7 @@ class RESTClientObject:
return {{httpxModule}}.AsyncClient(
limits=limits,
proxy=proxy,
timeout=5 * 60,
verify=self.ssl_context,
trust_env=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def request(

post_params = post_params or {}
headers = httpx.Headers(headers or {})
timeout = _request_timeout or 5 * 60
timeout = _request_timeout or httpx.USE_CLIENT_DEFAULT

if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
Expand Down Expand Up @@ -196,6 +196,7 @@ def _create_pool_manager(self) -> httpx.AsyncClient:
return httpx.AsyncClient(
limits=limits,
proxy=proxy,
timeout=5 * 60,
verify=self.ssl_context,
trust_env=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def request(

post_params = post_params or {}
headers = httpx.Headers(headers or {})
timeout = _request_timeout or 5 * 60
timeout = _request_timeout or httpx.USE_CLIENT_DEFAULT
Comment thread
retrry marked this conversation as resolved.
Resolved

if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
Expand Down Expand Up @@ -196,6 +196,7 @@ def _create_pool_manager(self) -> httpx.AsyncClient:
return httpx.AsyncClient(
limits=limits,
proxy=proxy,
timeout=5 * 60,
verify=self.ssl_context,
trust_env=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def request(

post_params = post_params or {}
headers = httpx2.Headers(headers or {})
timeout = _request_timeout or 5 * 60
timeout = _request_timeout or httpx2.USE_CLIENT_DEFAULT
Comment thread
retrry marked this conversation as resolved.
Resolved

if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
Expand Down Expand Up @@ -196,6 +196,7 @@ def _create_pool_manager(self) -> httpx2.AsyncClient:
return httpx2.AsyncClient(
limits=limits,
proxy=proxy,
timeout=5 * 60,
verify=self.ssl_context,
trust_env=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,31 @@ def handle(request):
finally:
await rest.close()

async def test_client_timeout_applies_without_request_timeout(self):
requests = []

def handle(request):
requests.append(request)
return httpx2.Response(200)

rest = RESTClientObject(Configuration())
rest.pool_manager = httpx2.AsyncClient(
transport=httpx2.MockTransport(handle), timeout=httpx2.Timeout(7, connect=3),
)
try:
await rest.request("GET", "https://example.test/pet")
self.assertEqual(requests[-1].extensions["timeout"]["connect"], 3)
self.assertEqual(requests[-1].extensions["timeout"]["read"], 7)
finally:
await rest.close()

async def test_default_client_timeout(self):
pool = RESTClientObject(Configuration())._create_pool_manager()
try:
self.assertEqual(pool.timeout, httpx2.Timeout(5 * 60))
finally:
await pool.aclose()

async def test_proxy_and_tls_configuration(self):
config = Configuration()
config.proxy = "http://localhost:8080"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async def request(

post_params = post_params or {}
headers = httpx2.Headers(headers or {})
timeout = _request_timeout or 5 * 60
timeout = _request_timeout or httpx2.USE_CLIENT_DEFAULT

if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'
Expand Down Expand Up @@ -196,6 +196,7 @@ def _create_pool_manager(self) -> httpx2.AsyncClient:
return httpx2.AsyncClient(
limits=limits,
proxy=proxy,
timeout=5 * 60,
verify=self.ssl_context,
trust_env=True
)
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ def handle(request):
finally:
await rest.close()

async def test_client_timeout_applies_without_request_timeout(self):
requests = []

def handle(request):
requests.append(request)
return httpx2.Response(200)

rest = RESTClientObject(Configuration())
rest.pool_manager = httpx2.AsyncClient(
transport=httpx2.MockTransport(handle), timeout=httpx2.Timeout(7, connect=3),
)
try:
await rest.request("GET", "https://example.test/pet")
self.assertEqual(requests[-1].extensions["timeout"]["connect"], 3)
self.assertEqual(requests[-1].extensions["timeout"]["read"], 7)
finally:
await rest.close()

async def test_default_client_timeout(self):
pool = RESTClientObject(Configuration())._create_pool_manager()
try:
self.assertEqual(pool.timeout, httpx2.Timeout(5 * 60))
finally:
await pool.aclose()

async def test_proxy_and_tls_configuration(self):
config = Configuration()
config.proxy = "http://localhost:8080"
Expand Down
Loading