Restore threaded service management and thread-aware launcher#3350
Restore threaded service management and thread-aware launcher#3350MelkorBalrog wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| thread = thread_manager.register("main_app", module.main, daemon=False) | ||
| thread.join() |
There was a problem hiding this comment.
[P1] Unregister main thread before ThreadManager can respawn it
The new main() flow registers the application’s entry point with thread_manager and only calls thread_manager.unregister("main_app") after joining the returned thread. ThreadManager automatically restarts any registered thread that terminates, so there is a race: if module.main returns or raises and the monitor runs before unregister executes, a fresh non-daemon thread is spawned. The join waits only for the original thread, while the replacement thread continues running unjoined and may block process shutdown or execute module.main twice. To avoid this, unregister (and join the returned thread) before the monitor can respawn the worker, or otherwise disable auto-restart for this one-shot task.
Useful? React with 👍 / 👎.
Summary
Testing
radon cc -j AutoML.py tools/memory_manager.py mainappsrc/services/service_manager.py tests/test_launcher_threading.py tests/test_thread_manager.pypytest tests/services/test_service_manager.py tests/test_launcher_threading.py tests/test_thread_manager.py -qpytest --maxfail=1 -qhttps://chatgpt.com/codex/tasks/task_b_68b1b3ed48f88327ae3920fefe4e8025