Skip to content

[codex] Suppress notification snapshot timeout tracebacks#1192

Merged
axisrow merged 1 commit into
mainfrom
ao/tg_content_factory_5863f66be3-5/issue-1172-notification-timeout
Jun 28, 2026
Merged

[codex] Suppress notification snapshot timeout tracebacks#1192
axisrow merged 1 commit into
mainfrom
ao/tg_content_factory_5863f66be3-5/issue-1172-notification-timeout

Conversation

@axisrow

@axisrow axisrow commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #1172.

  • Handle asyncio.TimeoutError separately while refreshing the notification bot snapshot.
  • Log a single warning line for expected network timeouts instead of routing them through the generic exc_info=True handler.
  • Keep the generic exception path unchanged so unexpected failures still include a traceback.
  • Add a runtime worker test that asserts the timeout warning is logged and no Traceback appears in caplog.

Validation

  • ruff check src/ tests/ conftest.py passed.
  • pytest tests/test_runtime_worker.py -v passed: 19 passed.
  • pytest tests/ -v -m "not aiosqlite_serial" -n auto failed on unrelated existing/local-environment tests: tests/test_quality_scoring_service.py::{test_score_content_uses_default_provider,test_score_and_check_with_default_provider,test_score_and_check_custom_threshold_higher,test_score_content_long_string} and tests/test_pipelines.py::test_pipelines_page_renders.
  • pytest tests/ -v -m aiosqlite_serial failed on unrelated existing/local-environment timeout: tests/test_agent_tool_smoke_contract.py::test_deepagents_all_tools_smoke_with_minimal_contract_args.

@axisrow axisrow marked this pull request as ready for review June 28, 2026 17:38
@axisrow axisrow merged commit e8b1d5e into main Jun 28, 2026
4 checks passed

@axisrow axisrow left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: APPROVE — готов к мержу

Чистый, точечный фикс под #1172. Поведение корректно, тест валидирует acceptance-критерии напрямую.

Корректность подтверждена:

  • Порядок except-клауз верный: CancelledError (BaseException, не ловится except Exception) → новый TimeoutError → generic Exception. Новая клауза стоит ПЕРЕД except Exception, иначе не сработала бы.
  • Источник таймаута — asyncio.wait_for(client.get_me(), timeout=15.0) в notification_service.py:77. На Python 3.12 (этот репо) wait_for при таймауте кидает TimeoutError напрямую — новая клауза ловит его корректно. asyncio.TimeoutError — алиас builtin TimeoutError с 3.11.
  • Нет утечки клиента: use_client() (notification_target_service.py:211-214) освобождает клиент в finally, TimeoutError из тела async with корректно триггерит release_client.
  • Внешний asyncio.wait_for(_publish_snapshots(...), timeout=publish_timeout) не задет: его таймаут даёт CancelledError внутри корутины (ловится клаузой на 212), а не TimeoutError — новая клауза ловит только внутренний 15s-таймаут get_me(), как и задумано.
  • exc_info не передаётся → стека в логе нет, что и проверяет assert "Traceback" not in caplog.text.

Проверки:

  • ruff check src/runtime/worker.py tests/test_runtime_worker.py — clean.
  • Новый тест test_publish_snapshots_notification_bot_timeout_is_nonfatal — PASSED (0.07s). Зеркалит существующий cancelled-path тест, ассертит и наличие короткого WARNING, и отсутствие трейсбэка.

Замечания (необязательные, не блокеры):

  • Опциональный пункт из issue (throttle/дедуп повторных WARNING раз в N) не реализован — он был помечен как опциональный, оставление на потом приемлемо.
  • connection-таймауты помимо TimeoutError (например ConnectionError от Telethon при флапе) по-прежнему пойдут в generic except Exception с полным трейсбэком. Issue прямо упоминает только TimeoutError как наблюдаемый случай, так что для закрытия #1172 этого достаточно; если в логах всплывут ConnectionError-стеки — отдельным фиксом.

Failing-тесты из описания PR (test_quality_scoring_service, test_pipelines_page_renders, test_deepagents_all_tools_smoke) не связаны с диффом — окружение/существующие. Дифф их не затрагивает.

Вердикт: approved.

Comment thread src/runtime/worker.py
raise
logger.warning("Notification bot snapshot refresh was cancelled; continuing worker")
except asyncio.TimeoutError:
logger.warning("Notification bot snapshot timed out (network); continuing")

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Корректно: ловит внутренний таймаут get_me() (notification_service.py:77, asyncio.wait_for(..., timeout=15.0)). Клауза стоит перед except Exception — порядок важен, иначе generic-путь перехватил бы первым. asyncio.TimeoutError == builtin TimeoutError (Py 3.11+), так что покрывает и тот, и другой. Внешний publish-wait_for не задет (он даёт CancelledError, ловится выше).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(worker): не спамить полным трейсбэком при таймауте снапшота нотификейшн-бота

1 participant