Skip to content

Error of in-flight requests using streaming response #2118

Discussion options

You must be logged in to vote

Hi @gtsystem, it seems an asynchronous generators finalization problem, FYI: https://peps.python.org/pep-0525/#finalization

Close the generator manually can resolve the problem.

async def main():
    client = httpx.AsyncClient()
    agen = read_lines(client)
    async for json_line in agen:
        print(json_line)
        break  # we interrupt reading the stream
    await agen.aclose()  # --> close it manually
    await client.aclose()

Replies: 1 comment 1 reply

Comment options

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

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