Summary
Streamlit 1.20.0 contains a callbacks module that seems intended to provide timed (periodic/later/at) callbacks that play nicely with streamlit. The module fails to import, not finding StopException. Is this module under development?
Steps to reproduce
Code snippet:
from streamlit.callbacks.callbacks import periodic
To reproduce: just try the import into a Python environment that otherwise imports st modules fine.
Expected behavior:
If the module worked, the following should be possible, hopefully while keeping st responsive in between calls.
Code snippet:
from streamlit.callbacks.callbacks import periodic
em = st.empty()
sec_counter = -1
my_callback()
periodic(2.0, my_callback)
def my_callback(em):
self.sec += 1
em.write(f"~{self.sec} sec")
Actual behavior:
ImportError: cannot import name ‘StopException’ from ‘streamlit’ (…/site-packages/streamlit/init.py)
Debug info
- Streamlit version: 1.20.0
- Python version: 3.10.9
- Using Conda
- OS version: MacOS Monteray (10.4)
- Browser version: n/a
Additional information
There are many timer solutions on the Web that attempt to create the timed callback functionality without sleep(), which would render st unresponsive. Having this apparently intended callback work would ensure it’s done properly in the context of st. Many uses, e.g. periodically checking a queue.