How to write lines continuously without newlines into a st.code object


I’m trying to write dynamic log output into a streamlit app.
The code does something like that atm:

for line in generator:

The output looks quite ugly (containing an empty line between the code blocks) e.g.:




I know that above is not the way how to achieve it.
st.code will always generate a new code object. I would like to append lines to an
existing st.code object. The lines are coming dynamically in with delay. Hence I cannot
generate the code block first and write it at once.
Any idea how to accomplish it?


Solution was quite easy:

block = ""
    for line in streamer.start():
            block = f"{block}\n{line}"

sorry for the noise

Problem with this code is that the “block” variable will be grow line by line and send with each incoming new line again. That leads to errors like:

Traceback (most recent call last):
  File "/data/git/progs/python/streaml_vmware/venv/lib64/python3.8/site-packages/tornado/", line 1104, in wrapper
    raise WebSocketClosedError()

because to much data will be sent within to short time frames.
So I need a better solution where I can append strings to an already existing st.code object.