Abnormal delays when using threads

One thought on “Abnormal delays when using threads

  1. We are doing HTTP communication on a background thread in order to keep the communication channel with the main MCU free and responsive. Today I noticed that sometimes there is a really long delay from when we begin setting up a socket to when the HTTP request is finished and the socket is closed:


    1142.626 DataHandler.py:26 Task started
    1142.639 DataHandler.py:23 Create session
    1142.677 Http.py:3 GET http://……, parameters=None, headers=None
    1148.812 EHttp.py:79 Creating socket
    1148.829 EHttp.py:80 Setting socket options
    1148.840 EHttp.py:84 Setting TCP_NODELAY
    1148.851 EHttp.py:84 Connecting

    1150.093 EHttp.py:47 Closing socket 


    After the thread has been created it takes 6 seconds before the thread can continue setting up the socket. Is this normal?

    sys.getcheckinterval() is 100.

    EDIT: It seems like the delay only exists on the first HTTP call. After that, the entire request takes around 400ms.