Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.
Merged
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
12 changes: 11 additions & 1 deletion api_reflector/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import requests

from api_reflector.reporting import get_logger
from settings import settings

log = get_logger(__name__)

Expand All @@ -29,7 +30,16 @@ def delay(*args, **_kwargs) -> None:
Sleep for an amount of time.
Takes a single positional argument; the number of seconds to sleep for.
"""
time.sleep(float(args[0]))
length = float(args[0])

if settings.maximum_delay_length is not None and length > settings.maximum_delay_length:
log.warning(
f"Delay length of {length} seconds exceeds maximum of {settings.maximum_delay_length} seconds. "
"Delay will be clamped to the configured maximum."
)
length = min(length, settings.maximum_delay_length)

time.sleep(length)


def process_callback(*args, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class Settings(BaseSettings):

trace_query_descriptions: bool = False

# in seconds. delays will not last longer than this.
maximum_delay_length: Optional[float] = None

@validator("azure_client_id", "azure_client_secret", "azure_tenant")
@classmethod
def enabled_auth_settings(cls, v: Optional[str], values: Mapping[str, Any]) -> Optional[str]:
Expand Down