I have a Python program that sends several requests (about 5-6) of poll requests in parallel, using different threads for each poll through a packet of requests. And I realized that some of my threads sometimes just freeze. When this happens, the server to which I am sending the request does not receive the request. I also set a timeout in the request, and it does not work.
try: print("This line prints") response = requests.head(poll_request_url, timeout=180) print("This line does not print when freeze occurs") except ReadTimeout: print("Request exception.") except RequestException as e: print("Request exception.") except Exception: print("Unknown exception.") print("This line does not print either when freeze occurs.")
I do this on a Raspberry Pi 2 machine with the Raspbian operating system.
I used the same program without problems when I used Python 2.7. I recently switched to Python 3.5. I tested using both versions of queries from 2.8.1 and 2.9.1.
This problem does not occur often, but occurs 2-3 times a day on different threads.
What could be the problem? How can I debug this?
Edit: The problem was resolved by updating the Linux kernel.
python multithreading long-polling python-requests
Canol gökel
source share