Streamlit disturbs another thread in application

Hello,
I am having a thread in app. It connects to TCP. host=β€œ192.168.1.103”, port=8899.
I read modbusRTU throug that port

I start it like this:

   st.set_page_config(
    page_title="data",
    page_icon="βœ…",
    layout="wide",
    )

    if 'thread' not in st.session_state:
        
        x = threading.Thread(target=teekoo, args=(), name="t 1")
        x.start()
        st.session_state['thread'] = x.name
        st.write(st.session_state.thread)
    x.name
    sleep(100)

If I run only thread

x = threading.Thread(target=teekoo, args=())
x.start()

It runs just fine. When ran it in Streamlit app, I start getting all kinds of errors.

e.g. Error while flushing the socket: flush_socket: maximum number of iterations reached

Are the thread and Streamlit app somehow fighting for same resources?