Repository navigation
Conversation
`Stream.wait_closed()` was a no-op, so callers of `open_udp_connection` could not wait for the spawned UDP client task to finish. This matters when shutting down: the task may still log after Python has moved on. Make `wait_closed` wait until the task has finished. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0822dee1-89da-4338-994f-bf1a11052c0e
|
I'm curious: What's the use case for waiting for the underlying UDP task to finish? I mean I understand the general appeal of wait_closed not being a no-op, but why specifically (only) UDP? :) |
|
Good question! The concrete case is a segfault at shutdown. The task spawned by It's UDP-only because that's the only |
Preserve both the UDP completion and server-closure regressions, initializing completion tracking for the upstream stream fixture. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cfacfee1-d3e5-4b4d-9b9f-2712008a29e6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cfacfee1-d3e5-4b4d-9b9f-2712008a29e6
|
Ah, so this is vorner/pyo3-log#30 again. I really wonder if it's worth fixing this whack-a-mole, or if we should rather patch pyo3-log to not be a pain in the butt anymore (there's vorner/pyo3-log#78 for instance). Do you have any thoughts on that? |
|
Sorry, missed this until now. I agree that there should be a fix to the late logging issue independent of this fix, but this fix is still an improvement to the code on its own, so that the wait actually waits, to avoid other possible issues where shutdown isn't clean. |
Stream.wait_closed()is currently a no-op, so callers ofopen_udp_connectioncan't wait for the spawned UDP client task to finish. For example, it may still log after the Python side has torn down.UDP client streams now hold a
watch::Receiverwhose sender is dropped when the task finishes, andwait_closedwaits for that. Streams from servers are unchanged.mitmproxy needs to await this after closing a stream. That change is in mitmproxy/mitmproxy#8456.