is there a example to implement IOStream.read_until_close(streaming_callback)

24 views
Skip to first unread message

Jim Simon

unread,
Mar 19, 2021, 7:57:45 AM3/19/21
to Tornado Web Server
Hi guys,
is there an example to implement IOStream.read_until_close(streaming_callback=) via Tornado 6.x ?


Ben Darnell

unread,
Mar 20, 2021, 11:45:04 AM3/20/21
to Tornado Mailing List
You'll need to use read_bytes(n, partial=True) in place of read_until_close(streaming_callback=...). You may have to restructure your code a bit to do this. 

Instead of

    stream.read_until_close(streaming_callback=handle_data)

Use

    try:
        while True:
            handle_data(await stream.read_bytes(65536, partial=True))
    except StreamClosedError:
        pass

-Ben

On Fri, Mar 19, 2021 at 7:57 AM Jim Simon <kevinl...@gmail.com> wrote:
Hi guys,
is there an example to implement IOStream.read_until_close(streaming_callback=) via Tornado 6.x ?


--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-tornado/59028a0b-45ad-4f27-ac95-d2b8d33f2ba0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages