Potential bug in keep_subprocess_alive method: Unexpected behavior when modifying list during iteration - New multiprocess manager #2372
-
Related to New multiprocess manager update This issue has been observed in a production environment where some worker processes became unresponsive. Instead of terminating these unresponsive workers, the parent process continued to spawn new workers. This resulted in an accumulation of unresponsive worker processes, as they were not being correctly removed from the self.processes list. To reproduce the issue, I've added a return False to the process.is_alive method. Here's the output when running the server with two workers. I've added some print to emphasize the issue (process
Possible solution to this bug:
A more simplified python example, to emphasise the issue
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
For deleting by index, it's sufficient to iterate in reverse. This ensures that any moved elements have already been processed and that newly appended element are not processed. So instead of uvicorn/uvicorn/supervisors/multiprocess.py Line 166 in 44a3071 it should suffice to do
instead. There are various alternatives to code this ("enumerate in reverse") as per personal preference. |
Beta Was this translation helpful? Give feedback.
-
Since process are deleted and then replaced it should also be sufficient to just replace them. This ensures the remaining elements are kept in place. So instead of uvicorn/uvicorn/supervisors/multiprocess.py Lines 177 to 180 in 44a3071 it should suffice to do
instead. |
Beta Was this translation helpful? Give feedback.
-
please use hypercorn ! I have stack in this problem 2days! https://blog.csdn.net/gitblog_00116/article/details/141153910 |
Beta Was this translation helpful? Give feedback.
Since process are deleted and then replaced it should also be sufficient to just replace them. This ensures the remaining elements are kept in place.
So instead of
uvicorn/uvicorn/supervisors/multiprocess.py
Lines 177 to 180 in 44a3071
it should suffice to do
instead.