added max_clients arg to get_default_session/cycle timeout seconds

This commit is contained in:
TPV committed 2026-07-27 12:02:41 -07:00
1 parent 99e68b1fa9
commit 1e53904cc6
10 files changed
+1474 -2

No files matched your search

+66
View File
@@ -0,0 +1,66 @@
"""Shared constants for monitors and the consumer bot.
Holds Mongo connection settings, bot tokens, retry and timeout tuning,
client fingerprint identifiers, webhook routing maps, product status values,
and the expected error tuple used for known-failure handling.
"""
import asyncio
from enum import Enum
from json import JSONDecodeError
import aiohttp
import requests
from aioweb import AiowebError
from curl_cffi.requests.errors import RequestsError
from pymongo.errors import PyMongoError
MONGO_DATABASE_NAME = "tpv_woot"
MONGO_URL = (
"mongodb://tpv:n3%23QI07GnbZCbvGJ@zelda.disqualifier.me:27017/?authSource=tpv_woot"
)
LOGGING_LEVEL = "INFO"
LOGGERS = [
"discord",
"pymongo",
"aiohttp",
]
RETRY_LIMIT = 5
RETRY_WAIT = 3
CYCLE_DELAY = 0.30
MIN_BACKOFF_DELAY = 0.1
MAX_BACKOFF_DELAY = 2.0
FAILURE_DELAY = 3
TIMEOUT_SECONDS = 30
CYCLE_TIMEOUT_SECONDS = 600
# curl_cffi's AsyncSession defaults to 10 handles and blocks on an untimed
# pool.get() past that, so a monitor fanning out wider silently serialises with
# no timeout covering the wait. Handles are allocated lazily (the pool holds
# None placeholders until popped), so a generous ceiling costs a low-concurrency
# monitor nothing. Monitors fanning out past this pass max_clients explicitly.
MAX_CURL_HANDLES = 64
CLIENT_IDENTIFIERS = ["chrome", "chrome_android", "safari", "safari_ios"]
CLIENT_TIMEOUT = aiohttp.ClientTimeout(
total=TIMEOUT_SECONDS, sock_connect=30, sock_read=30
)
EXPECTED_TASK_ERRORS = (
RequestsError,
aiohttp.ClientError,
asyncio.TimeoutError,
requests.Timeout,
requests.HTTPError,
PyMongoError,
JSONDecodeError,
AiowebError,
)
class ProductStatus(str, Enum):
"""Lifecycle status for a monitored product document."""
PENDING = "pending"
SENT = "sent"
SKIPPED = "skipped"
FAILED = "failed"