Skip to content

Commit

Permalink
Extend default HTTP timeouts from 5s to 30s
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtemple committed May 10, 2024
1 parent 1d7b5cd commit 1f0252f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions spectacles/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

__version__ = importlib.metadata.version("spectacles")

# How long to wait when the network is inactive
# https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration
DEFAULT_HTTP_TIMEOUT = httpx.Timeout(30)


class ConfigFileAction(argparse.Action):
"""Parses an arbitrary config file and assigns its values as arg defaults."""
Expand Down Expand Up @@ -791,7 +795,7 @@ async def run_connect(
) -> None:
"""Tests the connection and credentials for the Looker API."""
# Don't trust env to ignore .netrc credentials
async_client = httpx.AsyncClient(trust_env=False)
async_client = httpx.AsyncClient(timeout=DEFAULT_HTTP_TIMEOUT, trust_env=False)
try:
LookerClient(
async_client, base_url, client_id, client_secret, port, api_version
Expand All @@ -816,7 +820,7 @@ async def run_lookml(
timeout: int,
) -> None:
# Don't trust env to ignore .netrc credentials
async_client = httpx.AsyncClient(trust_env=False)
async_client = httpx.AsyncClient(timeout=DEFAULT_HTTP_TIMEOUT, trust_env=False)
try:
client = LookerClient(
async_client, base_url, client_id, client_secret, port, api_version
Expand Down Expand Up @@ -875,7 +879,7 @@ async def run_content(
use_personal_branch: bool,
) -> None:
# Don't trust env to ignore .netrc credentials
async_client = httpx.AsyncClient(trust_env=False)
async_client = httpx.AsyncClient(timeout=DEFAULT_HTTP_TIMEOUT, trust_env=False)
try:
client = LookerClient(
async_client, base_url, client_id, client_secret, port, api_version
Expand Down Expand Up @@ -936,7 +940,7 @@ async def run_assert(
concurrency: int,
) -> None:
# Don't trust env to ignore .netrc credentials
async_client = httpx.AsyncClient(trust_env=False)
async_client = httpx.AsyncClient(timeout=DEFAULT_HTTP_TIMEOUT, trust_env=False)
try:
client = LookerClient(
async_client, base_url, client_id, client_secret, port, api_version
Expand Down Expand Up @@ -999,7 +1003,7 @@ async def run_sql(
) -> None:
"""Runs and validates the SQL for each selected LookML dimension."""
# Don't trust env to ignore .netrc credentials
async_client = httpx.AsyncClient(trust_env=False)
async_client = httpx.AsyncClient(timeout=DEFAULT_HTTP_TIMEOUT, trust_env=False)
try:
client = LookerClient(
async_client, base_url, client_id, client_secret, port, api_version
Expand Down

0 comments on commit 1f0252f

Please sign in to comment.