def _run_exodus(*args):
'''Run a Exodus using runpy
'''
fullpath = path.join(config.addonsdir, config.exodus['id'], config.exodus['entryfile'])
entrypath, entryfile = path.split(fullpath)
if entrypath not in sys.path:
sys.path.insert(0, entrypath)
module, _ = path.splitext(entryfile)
# Exodus assumes thread names start at 1
# and gets provider names from the thread name
c = threading._counter = count().next
c() # consume 0
sys.argv = list(args)
# note: cannot use __import__ because Exodus spawns threads that do import
# so that would cause deadlock
old_modules = set(sys.modules.keys()) # unload the newly added modules after runpy
runpy.run_module(module)
for k in set(sys.modules.keys()) - old_modules:
del sys.modules[k]
评论列表
文章目录