forgot to commit docstrings for runner.py

This commit is contained in:
tpv committed 2026-07-06 10:06:49 -07:00
1 parent 54881acaee
commit b0319f6ada
1 file changed
+10 -1
+10 -1
View File
@@ -58,6 +58,7 @@ def init_monitor(
Returns: Returns:
Tuple of category names, Mongo collection, and loaded proxies. Tuple of category names, Mongo collection, and loaded proxies.
""" """
use_production = is_production(development_mode) use_production = is_production(development_mode)
setup_logging( setup_logging(
name="logs/latest.log", name="logs/latest.log",
@@ -90,6 +91,7 @@ def setup_config(
Returns: Returns:
Tuple of category names, channel id mapping, and Mongo collection. Tuple of category names, channel id mapping, and Mongo collection.
""" """
use_production = is_production(development_mode) use_production = is_production(development_mode)
config, _ = get_config( config, _ = get_config(
monitor_name=monitor_name, monitor_name=monitor_name,
@@ -122,6 +124,7 @@ def get_channel_id(
Returns: Returns:
The resolved channel id. The resolved channel id.
""" """
if product.availability.app_exclusive: if product.availability.app_exclusive:
return get_single_channel_id(channel_ids["appExclusive"]) return get_single_channel_id(channel_ids["appExclusive"])
@@ -147,6 +150,7 @@ def get_channel_id(
def get_single_channel_id(value: str | list[str]) -> str: def get_single_channel_id(value: str | list[str]) -> str:
"""Return the first channel id when given a list, else the value itself.""" """Return the first channel id when given a list, else the value itself."""
if isinstance(value, list): if isinstance(value, list):
return value[0] return value[0]
@@ -174,6 +178,7 @@ def build_product_details(
Returns: Returns:
The built Product, or None when skipped or below thresholds. The built Product, or None when skipped or below thresholds.
""" """
product_id = product["_id"] product_id = product["_id"]
current_price = product["currentPrice"] current_price = product["currentPrice"]
original_price = product["originalPrice"] original_price = product["originalPrice"]
@@ -259,6 +264,7 @@ async def execute_monitor_logic(
use_tls: Use the TLS fingerprint session instead of the base session. use_tls: Use the TLS fingerprint session instead of the base session.
**kwargs: Forwarded verbatim to pre_task_func and every task_func call. **kwargs: Forwarded verbatim to pre_task_func and every task_func call.
""" """
while True: while True:
session_ctx = ( session_ctx = (
get_tls_session( get_tls_session(
@@ -344,6 +350,7 @@ async def execute_pagination(
query_category_id) must be supplied here, since naming varies query_category_id) must be supplied here, since naming varies
per monitor. per monitor.
""" """
LOGGER.info("executing pagination", extra={"category": category_identifier}) LOGGER.info("executing pagination", extra={"category": category_identifier})
total_pages = (int(total_products) + products_per_page - 1) // products_per_page total_pages = (int(total_products) + products_per_page - 1) // products_per_page
semaphore = asyncio.Semaphore(max_concurrent_tasks) semaphore = asyncio.Semaphore(max_concurrent_tasks)
@@ -410,6 +417,7 @@ async def fetch_all_pages(
Returns: Returns:
Page numbers whose fetch raised an expected error. Page numbers whose fetch raised an expected error.
""" """
tasks = [fetch_func(page) for page in page_range] tasks = [fetch_func(page) for page in page_range]
results = await asyncio.gather(*tasks, return_exceptions=True) results = await asyncio.gather(*tasks, return_exceptions=True)
return handle_page_results( return handle_page_results(
@@ -440,8 +448,8 @@ def handle_page_results(
Returns: Returns:
Page numbers whose fetch raised an expected error. Page numbers whose fetch raised an expected error.
""" """
failed_pages = []
failed_pages = []
for page_number, result in zip(page_numbers, results): for page_number, result in zip(page_numbers, results):
if isinstance(result, EXPECTED_TASK_ERRORS): if isinstance(result, EXPECTED_TASK_ERRORS):
LOGGER.warning( LOGGER.warning(
@@ -503,6 +511,7 @@ async def retry_failed_pages(
Returns: Returns:
Page numbers still failing after all retries. Page numbers still failing after all retries.
""" """
retry_attempt = 1 retry_attempt = 1
while failed_pages and retry_attempt <= max_retries: while failed_pages and retry_attempt <= max_retries:
await asyncio.sleep(2**retry_attempt) await asyncio.sleep(2**retry_attempt)