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