When I programmatically apply a classifier to an image, not all threads seem to be closed after processing.
This issue hit me when trying to use WekaSegmentation via pyimagej from Python, where the Python process hangs indefinitely after processing. See https://github.com/fmi-faim/faim-wako-searchfirst/pull/57 and this example run for a test that passes, but the GitHub Actions job needed to cancelled because it was hanging forever. I tried calling scyjava.shutdown_jvm() after classifying, but that made it hang before showing the pytest output.
Consider the following Groovy script:
#@ ImagePlus imp
#@ File classifier
import trainableSegmentation.WekaSegmentation
ws = new WekaSegmentation(imp)
ws.loadClassifier(classifier.getAbsolutePath())
ws.applyClassifier(false)
result = ws.getClassifiedImage()
After running the script on the current open image, I see many new threads in Plugins > Utilities > Threads:
When I programmatically apply a classifier to an image, not all threads seem to be closed after processing.
This issue hit me when trying to use
WekaSegmentation
viapyimagej
from Python, where the Python process hangs indefinitely after processing. See https://github.com/fmi-faim/faim-wako-searchfirst/pull/57 and this example run for a test that passes, but the GitHub Actions job needed to cancelled because it was hanging forever. I tried callingscyjava.shutdown_jvm()
after classifying, but that made it hang before showing thepytest
output.Consider the following Groovy script:
After running the script on the current open image, I see many new threads in Plugins > Utilities > Threads:
After a couple of minutes, some of these are still hanging around:
After a second call of the script:
And again, a couple of minutes later:
It seems a few threads are quite persistent.