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”, 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\", 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\", line 230, in write
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\elements\", line 167, in flush_buffer
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\elements\", line 79, in markdown
    return self.dg._enqueue("markdown", markdown_proto)
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\", line 403, in _enqueue
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\", line 758, in _enqueue_message
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\", line 112, in enqueue
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\", line 190, in enqueue
  File "c:\users\kevin\documents\avionics\dash\venv\lib\site-packages\streamlit\", 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.