Files
pyrogram-bridge/tests/mock_config.py
T
vvzvlad 3c9ce72b51
Docker Image CI / build (push) Waiting to run
fix(media): self-heal zombie media-DC connection so images keep loading
Media downloads jammed process-wide: Kurigram serializes them through a single
get_file slot (max_concurrent_transmissions=1), and a zombie media-DC connection
(upload.GetFile timing out) held that slot forever. The main-DC watchdog (get_me)
never noticed, and the 60s cache sweep kept re-queuing the failing file, so all
feed images turned into broken placeholders.

- telegram_client: count consecutive download timeouts; after N (default 5) reuse
  _restart_client() to rebuild the media connection — the only recovery signal the
  main-DC watchdog cannot provide. Any success resets the streak.
- telegram_client/config: set max_concurrent_transmissions (default 3) so one hung
  download is no longer an instant total outage (blast-radius limiter only).
- api_server: negative-cache with exponential backoff for repeatedly-failing files
  (skip in background sweep, fast 503+Retry-After in get_media, record/clear in the
  dedup runner and background worker; FloodWait excluded).
- dockercompose/tests: document TG_MAX_CONCURRENT_TRANSMISSIONS and
  MEDIA_TIMEOUT_RESTART_THRESHOLD; update mock config; add self-heal/backoff tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 04:22:31 +03:00

44 lines
1.4 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def setup_logging(level_name: str = "INFO") -> None:
"""No-op logging setup for tests (mirrors config.setup_logging signature)."""
return None
def get_settings():
"""
Mock config for testing without requiring TG_API_ID and TG_API_HASH
"""
return {
"tg_api_id": 12345,
"tg_api_hash": "test_hash",
"session_path": "tests/test_data",
"api_host": "127.0.0.1",
"api_port": 8080,
"pyrogram_bridge_url": "http://test.example.com",
"log_level": "DEBUG",
"debug": False,
"token": "test_token",
"time_based_merge": False,
"show_bridge_link": False,
"show_post_flags": True,
"proxy": None,
"trusted_proxies": [],
"tg_rpc_timeout": 60,
"tg_watchdog_enabled": True,
"tg_watchdog_interval": 60,
"tg_watchdog_timeout": 10,
"tg_watchdog_failures": 3,
"tg_watchdog_restart_timeout": 90,
"tg_watchdog_heartbeat_every": 30,
"tg_disconnect_flap_limit": 3,
"tg_disconnect_flap_window": 120,
"tg_ping_unhealthy_after": 250,
"media_download_timeout_min": 120,
"media_download_timeout_max": 1800,
"media_download_min_speed": 256 * 1024,
"io_thread_pool_size": 32,
"tg_max_concurrent_transmissions": 3,
"media_timeout_restart_threshold": 5,
}