How to use Streamlit with VS Code?

Dear all,

I’d like to come back to this, since I ran into some trouble with streamlit and vscode.

I’d like to use async routines in my app and tested a little bit. Already with this script

import streamlit as st 
import asyncio
from datetime import datetime

st.set_page_config(layout="wide")

st.markdown(
    """
    <style>
    .time {
        font-size: 130px !important;
        font-weight: 700 !important;
        color: #ec5953 !important;
    }
    </style>
    """,
    unsafe_allow_html=True
)

async def watch(test):
    while True:
        test.markdown(
            f"""
            <p class="time">
                {str(datetime.now())}
            </p>
            """, unsafe_allow_html=True)
        res = await asyncio.sleep(1)

test = st.empty()

if st.button("Click me."):
    st.image("https://cdn11.bigcommerce.com/s-7va6f0fjxr/images/stencil/1280x1280/products/40655/56894/Jdm-Decals-Like-A-Boss-Meme-Jdm-Decal-Sticker-Vinyl-Decal-Sticker__31547.1506197439.jpg?c=2", width=200)

asyncio.run(watch(test))

which actually originates from Issue with asyncio run in streamlit, I got stuck.

The script starts without problems, however, when clicking ‘Click me’ I receive

Exception has occurred: RerunException       (note: full exception trace is shown but execution is paused at: watch)
RerunData(query_string='', widget_states=widgets {
  id: "$$GENERATED_WIDGET_KEY-d1af2ca94fbc523761576e0810c8012c-None"
  trigger_value: true
}
)
  File "/home/markus/Software/Python/streamlit/test1.py", line 28, in watch (Current frame)
    test.markdown(
  File "/home/markus/Software/Python/streamlit/test1.py", line 42, in <module>
    asyncio.run(watch(test))

in the line test.markdown.

Unfortunately, I have no clue, why this is happening, though it seems, that doing this in PyCharm does not run into this problem (I’d like to stay with VS Code).

Thanks a lot in advance for every hint!
Markus