Streamlit, asyncio and debugging in VS-code problem

Dear all,

I’d like to use async routines in my app and tested a little bit using vscode for debugging (see How to use Streamlit with VS Code? - #7 by w-markus). Already with this script

import streamlit as st 
import asyncio
from datetime import datetime


    .time {
        font-size: 130px !important;
        font-weight: 700 !important;
        color: #ec5953 !important;

async def watch(test):
    while True:
            <p class="time">
            """, unsafe_allow_html=True)
        res = await asyncio.sleep(1)

test = st.empty()

if st.button("Click me."):
    st.image("", width=200)

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/", line 28, in watch (Current frame)
  File "/home/markus/Software/Python/streamlit/", line 42, in <module>

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!

Dear all!

I think I found the root cause: in the side menu of vscode, one can tick mark whether execution is stopped and the editor is focused to the respective line of code upon certain exceptions:

Make sure, that “Uncaught Exceptions” is not marked, otherwise- I reckon - the RerunException issued by streamlit will be caught and lead to the breaks I have described above.

Happy scripting!