Sep-18-2020, 08:40 PM
I have an environment (tinycore linux) where as the system boots, python modules get loaded. The program needs to start up quickly, and it takes a while to load some modules like scipy.
In python2, this was not a problem, I could:
In python3, this does not work. I have to restart the process, it always fails even long after the module is available if it was not available when python3 started.
I tried
import importlib
importlib.invalidate_caches()
but this does not work either, it doesn't solve the problem.
I know it's possible to use multiprocessing and communicate over pipes to get around this issue but it's really making the code complicated and less efficient.
So, how do I get the interpreter to rescan the available modules after it's started since invalidate_caches doesn't do what it claims to?
In python2, this was not a problem, I could:
try: import scipy except: returnand try again later.
In python3, this does not work. I have to restart the process, it always fails even long after the module is available if it was not available when python3 started.
I tried
import importlib
importlib.invalidate_caches()
but this does not work either, it doesn't solve the problem.
I know it's possible to use multiprocessing and communicate over pipes to get around this issue but it's really making the code complicated and less efficient.
So, how do I get the interpreter to rescan the available modules after it's started since invalidate_caches doesn't do what it claims to?