Skip to content

Commit f1d3afc

Browse files
committed
feat: add request delay configuration and logging in main.py
1 parent e97e9a5 commit f1d3afc

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/python_response_time/core/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ class Settings(BaseSettings):
2121
TIMEOUT: Annotated[
2222
float, Field(gt=0, le=120, description="Request timeout in seconds")
2323
] = 10.0
24+
REQUEST_DELAY: Annotated[
25+
float, Field(gt=0, le=60, description="Delay between requests in seconds")
26+
] = 0.1
2427
LOG_LEVEL: Annotated[
2528
str, Field(pattern="^(DEBUG|INFO|WARNING|ERROR|CRITICAL)$")
2629
] = "INFO"

src/python_response_time/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
def run_app():
1414
"""Run a simple HTTP benchmark against the configured target URL."""
15+
logger.info(f"Target URL: {app_settings.TARGET_URL}")
16+
logger.info(f"Number of Requests: {app_settings.NUM_REQUESTS}")
17+
logger.info(f"Concurrency: {app_settings.CONCURRENCY}")
18+
logger.info(f"Timeout: {app_settings.TIMEOUT} seconds")
19+
logger.info(f"Request Delay: {app_settings.REQUEST_DELAY} seconds")
1520
logger.info("Starting HTTP benchmark...")
21+
1622
for i in range(app_settings.NUM_REQUESTS):
1723
start_time = time.time()
1824
try:
@@ -26,6 +32,8 @@ def run_app():
2632
)
2733
except requests.RequestException as e:
2834
logger.error(f"Request {i + 1} failed: {e}")
35+
finally:
36+
time.sleep(app_settings.REQUEST_DELAY)
2937

3038

3139
if __name__ == "__main__":

0 commit comments

Comments
 (0)