encode / uvicorn

An ASGI web server, for Python. 🦄
https://www.uvicorn.org/
BSD 3-Clause "New" or "Revised" License
8.11k stars 701 forks source link

Iterate subprocesses in-place #2373

Closed maxfischer2781 closed 2 days ago

maxfischer2781 commented 2 days ago

Summary

This PR fixes a subtle iterate-remove bug when checking subprocesses. Previously, subprocesses were deleted by index, which would shift the remaining processes and their index to go out of sync. This caused the wrong process to be deleted if more than one died in a cycle. See #2372.

Instead of being deleted-appended, process are now replaced inplace to ensure positions and thus iteration is stable. This also makes copying the process list superfluous, so I removed this where appropriate.

Checklist

abersheeran commented 2 days ago

This is definitely an oversight on my part.

Kludex commented 2 days ago

If someone creates a release PR (changelog + version change), I can make a release.