Skip to content
Discussion options

You must be logged in to vote

If you add an await asyncio.sleep(0), does it solve the problem?

async def async_streamer():
    try:
        while True:
            yield b"--boundary\r\nContent-Type: text/plain\r\nContent-Length: 1\r\n\r\n1\r\n"
            await asyncio.sleep(0)  # <--
    except asyncio.CancelledError:
        print("caught cancelled error")
        raise GeneratorExit

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@iudeen
Comment options

@Kludex
Comment options

@iudeen
Comment options

@Kludex
Comment options

Answer selected by iudeen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1775 on July 22, 2022 15:08.