"""Run `python -m ...` with numba's on-disk cache disabled. tiny-voca-dk: in the kit image, loading librosa's numba cache written by another process segfaults (cold compile is fine). With a process pool, the first worker writes the cache and the next ones crash while loading it (BrokenProcessPool). Forcing cache=False makes every process JIT-compile in memory; results are unchanged. Usage: python scripts/run_nocache.py -m tiny_voca.prepare --inputs ... """ import runpy import sys import numba def _without_cache(decorator): def wrapped(*args, **kwargs): kwargs.pop('cache', None) return decorator(*args, **kwargs) return wrapped for _name in ('jit', 'njit', 'vectorize', 'guvectorize', 'stencil'): if hasattr(numba, _name): setattr(numba, _name, _without_cache(getattr(numba, _name))) if len(sys.argv) < 3 or sys.argv[1] != '-m': raise SystemExit(__doc__) _module = sys.argv[2] sys.argv = [_module] + sys.argv[3:] runpy.run_module(_module, run_name='__main__', alter_sys=True)