tohil icon indicating copy to clipboard operation
tohil copied to clipboard

tohil + numpy + subinterpreters = fail

Open stevel6868 opened this issue 2 years ago • 0 comments

Not a tohil problem per se, but wondering if anyone has encountered this and resolved it.

I have a multithreaded Tcl program that does a bunch of calculations in each thread by tohil::call into a Python script that uses numpy. Results are fed back to Tcl via tohil.call to a Tcl proc. Works just fine with a single thread, but with multiple threads the second thread gets an error "Interpreter change detected - this module can only be loaded into one interpreter per process. (import module failed)" when running "import numpy".

It seems numpy explicitly doesn't like Python subintepreters. Does anyone have a workaround?

stevel6868 avatar Jul 20 '22 08:07 stevel6868