Slicer with custom Python threading crashing unpredictably

pedr0sorio
Sat, 24 May 2025 14:28:49 +0000
Development

Dear Slicer Community,

I have been building a custom slicer extension that allows me to do localised modifications in a CT scan using some AI models running in a Flask server that I access with requests.

The extension I implemented follows a structure similar to this MedSAM extension here.

My extension works well most of the time, but, at times, for reasons I have not been yet able to determine, I am encountering that Slicer suddenly crashes.

Things I have checked:

CPU and RAM usage before crash is not larger than usual.

Following this other issue documented in this community I have increased the cache size to 10000MBs. This seemed to decrease the frequency of the crashes but they still happen occasionally.

Crashes can happen right before/during I write some DICOM data to qt.QTemporaryDir() for later sending it to my server via requests. Although, they can also happen right after incorporating the predictions of the model into the scene.

Checking the logs after the crash in a new Slicer session are not informative. There aren’t any specific errors, just simply blank after my last debugging print.

The crashes don’t happen always but I need to understand how to avoid them completely. Do you have any ideas?

Thanks in advance!
Best,
Pedro

7 posts - 3 participants