# Streamlit disturbs another thread in application

**URL:** <https://discuss.streamlit.io/t/streamlit-disturbs-another-thread-in-application/64234>\
**Category:** Using Streamlit\
**Tags:** session-state, discussion\
**Created:** [March 8, 2024, 3:14pm UTC](https://discuss.streamlit.io/t/streamlit-disturbs-another-thread-in-application/64234 "2024-03-08T15:14:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lasse](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@Lasse](https://discuss.streamlit.io/u/Lasse)\
**Post date:** [March 8, 2024, 3:14pm UTC](https://discuss.streamlit.io/t/streamlit-disturbs-another-thread-in-application/64234/1 "2024-03-08T15:14:07Z")

</div>

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:

```auto
   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

```auto
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?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [September 4, 2024, 3:15pm UTC](https://discuss.streamlit.io/t/streamlit-disturbs-another-thread-in-application/64234/2 "2024-09-04T15:15:08Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
