Skip to content

Conversation

@KlochkovHF
Copy link
Contributor

https://huntflow.atlassian.net/browse/INT-1055
add worker healthcheck method

profiling_interval: Optional[float] = None,
on_stop_handlers: Optional[List[Coroutine]] = None,
exit_after_jobs: Optional[int] = None,
healthcheck_func: Optional[Callable[[], Coroutine]] = None,
Copy link

@alexreznikoff alexreznikoff Oct 2, 2025

Choose a reason for hiding this comment

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

кажется тут достаточно просто healthcheck, по аннотациям и так понятно что это функция. еще можно добавить заглушку, которая ничего не делает, если настоящий healthcheck не передан.

async def _healthcheck_stub():
    pass


class Worker:
    def __init__(
        ...
        healthcheck: Optional[Callable[[], Coroutine]] = None,
    ) -> None:
        self.queue_list = queue_list
        self._healthcheck = healthcheck or _healthcheck_stub

ну и ниже

while not self._stop_event.is_set():
    await self._healthcheck()

Кстати, в healthcheck возможно могут понадобится параметры, типа в какой файл писать или что-то другое, так что возможно в воркер нужно передавать уже готовую корутину, а не функцию?

class Worker:
    def __init__(
        ...
        healthcheck: Optional[Coroutine] = None,
    ) -> None:

self._periodic_poll_task: Optional[asyncio.Task] = None
self._exit_message: Optional[str] = None
self._healthcheck_func: Optional[Callable[[], Coroutine]] = healthcheck_func
self._healtchcheck: Optional[Callable[[], Coroutine]] = (

Choose a reason for hiding this comment

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

тут уже не Optional получается

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.73%. Comparing base (95318fd) to head (f0bf29c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
+ Coverage   88.67%   88.73%   +0.06%     
==========================================
  Files          23       23              
  Lines         715      719       +4     
  Branches       55       55              
==========================================
+ Hits          634      638       +4     
  Misses         73       73              
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

PROFILING_LOGGER.propagate = False


async def _healthcheck_stub():
Copy link
Contributor

Choose a reason for hiding this comment

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

-> None? :)

@KlochkovHF KlochkovHF merged commit 445228d into master Oct 2, 2025
8 checks passed
@KlochkovHF KlochkovHF deleted the INT-1055 branch October 2, 2025 11:52
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.

5 participants