Title: Resource leaks with threading.Thread
Type: resource usage Stage:
Components: Interpreter Core Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: POCEH, martin.panter, rahul-kumi, vstinner
Priority: normal Keywords:

Created on 2020-05-17 08:07 by POCEH, last changed 2020-05-24 01:13 by ned.deily.

File name Uploaded Description Edit POCEH, 2020-05-17 08:07
Messages (2)
msg369102 - (view) Author: Rosen Tomov (POCEH) Date: 2020-05-17 08:07
In my project I'm using intensively threading to transfer HTTP data - reading is in separate thread and the process run smoothly. However when I've try to optimize stopping of the process and attempt to use the daemon threads. The result was 'Can't start new thread' error under Linux. In order to investigate the issue I've create small test program and found more interesting problem: using non daemon threads leaks handles (under Windows/x64 Semaphore type), while under Linux looks like leaks some other resource, can't say exactly what. When using a daemon threads no leaks handles under Windows but under Linux, after long time running the problem arrives, the only one solution is to reboot of Linux/ARM64, restarting the Python process didn't help! Of course the problem could be race condition or some locking problem, didn't investigate further and in Python's core source. 
Attached test programs reveals the problem very quickly, using Python 3.8.x interpreters. Also I've testing with lambdas and deletion and found that they do not influence the behavior.
msg369762 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2020-05-24 01:01
Perhaps this is the same as Issue 37788, introduced in 3.7.
Date User Action Args
2020-05-24 01:13:50ned.deilysetnosy: + vstinner
2020-05-24 01:01:25martin.pantersetnosy: + martin.panter
messages: + msg369762
2020-05-18 16:39:34rahul-kumisetnosy: + rahul-kumi
2020-05-17 08:07:51POCEHcreate