Torchserve interaction with scipy and other packages

Hi, I am working on a project with Torchserve where an already implemented running service (torchserve) needs to be integrated with a numpy-scipy code. In particular, the numpy-scipy code uses some function for generating sparse arrays, solveds some equations etc. In particular, in the part of the code where scipy calls the linalg function (scipy.linalg.cg(…)) I notice a strange behaviour when calling from postprocess function, my local python file. In particular after executing the scipy.linalg.cg(…) function, service stops.
Any idea? Could this be an issue related with the interaction between scipy packages and torchserve? Should I integrate my code in the handler class instead of have it externally and call it from handler class?