Skip to content

Cancel request and depended spawned tasks for streamed data #85

Answered by robjtede
liketoeatcheese asked this question in Q&A
Discussion options

You must be logged in to vote

My reproduction of this using your code always results in the stream exiting after a few seconds. I suspect it has something to do with leftover TCP connections at the OS level keeping the HTTP server alive for a while. For me, at least, on macOS, this seems to resolve itself. Maybe you're seeing infinite looping on Linux?

A somewhat more reliable test I've found is to use cURL's --max-time flag, which seems to shut down the TCP connection in a cleaner way, such that the next loop iteration more often exits out.

See that it prints "closing connection" whereas just ctrl-c is a more forceful shutdown that is likely to leave OS resources hanging.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@liketoeatcheese
Comment options

Answer selected by liketoeatcheese
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants