Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] core: SIGXCPU in worker processes
odoo#30688 (6ce2d6e) added an indirection in prefork workers: Python-level signal handlers are delayed until native calls have ended (e.g. accept() or execute()). Running the actual work in a sub-thread allowed the main thread to handle signals in all cases. However there is apparently an issue with SIGXCPU on linux (possibly other cases as well): SIGXCPU is delivered to the child thread (if possible?) and Thread.join apparently stops it from redelivered to the main thread (Thread.join is signal-interruptible since 3.2 but possibly not Python-interruptible). Blocking SIGXCPU on the child thread causes the OS to deliver on the main thread and fixes the issue. Also split set_limits so it sets the signal handler in the parent thread but properly updates the soft limit in the child after each request, as the goal is to put a hard limit on the CPU time per request, not on the worker. 6ce2d6e would set the limit once then never update it, likely cycling workers more than desired. While at it: * block other signals with a handler set, they seem to work regardless on linux but other OS may have a different way of dispatching process-directed signals * unset signals which are set by the prefork server but whose set behavior makes no sense in workers: - TERM and CHLD were already unset - HUP is used to restart the server, workers can just be killed - TTIN and TTOU configure the number of workers closes odoo#39723 X-original-commit: 549bd19 Signed-off-by: Xavier Morel (xmo) <[email protected]>
- Loading branch information