-
Notifications
You must be signed in to change notification settings - Fork 1
[INT-1055] worker healthcheck #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
yatq/worker/runner.py
Outdated
| profiling_interval: Optional[float] = None, | ||
| on_stop_handlers: Optional[List[Coroutine]] = None, | ||
| exit_after_jobs: Optional[int] = None, | ||
| healthcheck_func: Optional[Callable[[], Coroutine]] = None, |
There was a problem hiding this comment.
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:
yatq/worker/runner.py
Outdated
| 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]] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут уже не Optional получается
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
yatq/worker/runner.py
Outdated
| PROFILING_LOGGER.propagate = False | ||
|
|
||
|
|
||
| async def _healthcheck_stub(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> None? :)
https://huntflow.atlassian.net/browse/INT-1055
add worker healthcheck method