Repository navigation
Add development reload for docket worker #634
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from .cli import app | ||
|
|
||
| app() | ||
| if __name__ == "__main__": | ||
| app() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import asyncio | ||
| from collections.abc import Callable, Coroutine | ||
| from typing import Any | ||
|
|
||
| from watchfiles import PythonFilter, run_process | ||
|
|
||
| from docket.cli._support import ( | ||
| LogFormat, | ||
| LogLevel, | ||
| set_logging_format, | ||
| set_logging_level, | ||
| ) | ||
|
|
||
|
|
||
| def _run_worker( | ||
| worker: Callable[[], Coroutine[Any, Any, None]], | ||
| logging_level: LogLevel, | ||
| logging_format: LogFormat, | ||
| ) -> None: | ||
| set_logging_level(logging_level) | ||
| set_logging_format(logging_format) | ||
| asyncio.run(worker()) | ||
|
|
||
|
|
||
| def run_with_reload( | ||
| worker: Callable[[], Coroutine[Any, Any, None]], | ||
| logging_level: LogLevel, | ||
| logging_format: LogFormat, | ||
| ) -> None: | ||
| run_process( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L97-L103 Useful? React with 👍 / 👎. |
||
| ".", | ||
| target=_run_worker, | ||
| args=(worker, logging_level, logging_format), | ||
| watch_filter=PythonFilter(), | ||
| ) | ||
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.
With
--reload, if a task module is edited to the same byte length within the same timestamp second as the bytecode currently in__pycache__(for example, a fastbefore→editedrename), Python can accept that timestamp-based.pycbecause it validates only the source's integer mtime and size. The watcher fires, but this invocation then imports the old bytecode and no event remains to retry, so users see the old task implementation;test_worker.py:172-177masks this case by forcing the mtime two seconds forward. Ensure reload children bypass or remove affected bytecode before importing the task collection.Useful? React with 👍 / 👎.