# RerunException problem every time I rerun my app

Whenever I shut down my app using Ctrl+C, and then rerun the app using “streamlit run app.py”, I get this exception:

streamlit.script_runner.RerunException: RerunData(query_string='', widget_states=widgets {
id: "$$GENERATED_WIDGET_KEY-348f780fe35000ea8fc10a21e368531d" int_value: 2 } widgets { id: "$$GENERATED_WIDGET_KEY-220fb4a715442516225745727ad27359"
int_value: 3
}
)


The traceback goes back to when I write to the app:

 File "C:\Users\Kevin\Documents\Avionics\dash\app.py", line 103, in arduino_listener
self.data_area.write(f"Data: {data}")
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\elements\write.py", line 230, in write
flush_buffer()
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\elements\write.py", line 167, in flush_buffer
self.dg.markdown(
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\elements\markdown.py", line 79, in markdown
return self.dg._enqueue("markdown", markdown_proto)
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\delta_generator.py", line 403, in _enqueue
_enqueue_message(msg)
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\delta_generator.py", line 758, in _enqueue_message
ctx.enqueue(msg)
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\report_thread.py", line 112, in enqueue
self._enqueue(msg)
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\report_session.py", line 190, in enqueue
scriptrunner.maybe_handle_execution_control_request()
File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\script_runner.py", line 220, in maybe_handle_execution_control_request
raise RerunException(data)


I should mention, if I close the website tab, this exception doesn’t occur.

EDIT: I’m think I’m starting to have an idea of why this happens. I’m using a publisher subscriber model to read from an Arduino. Basically, whenever the Arduino sends a message to the computer, my python handler publishes it, which triggers a callback in the subscriber, which then updates a graph on my app. This isn’t really how Streamlit works, it wants to update when buttons are pressed, so the fact that something else is dictating when it updates is strange and makes it think it’s being rerun, maybe.