Run a traced script in a loop leaks threads

I have traced a short script which creates four views and renders them into a png.
Now, I changed that to run in a loop for many input files. However, I see that the number of threads is rising after each run - which eventually leads to a situation where I can not fork new threads.

I have the following code after each loop run:

ResetSession()
Disconnect()
Connect()

While the rendering windows are closed, the threads are not.
Do I need to remove any other objects somewhere to terminate the open threads?

Do you have an simple example to reproduce this ?

So one thing first: while testing it, I found out that this problem seems to be in 5.6 only.
I also tested now with 5.7, where there is a constant number of threads open at the same time.
I’m now using 5.8-headless, which works also flawlessly. I could not get 5.7 to run on the machine I’m using…

Regardless, the script is attached.
mwe.py (6.5 KB)

1 Like