def create_executor(cls, allowCached=True): if not allowCached: return InMemorySimulationExecutorFactory.create_executor() if cls.executor is None: cls.executor = InMemorySimulationExecutorFactory.create_executor() cls.executor.stayOpenOnExit = True return cls.executor
def create_executor(self, **kwds): s3 = ActualS3Interface.ActualS3InterfaceFactory() if 'threadsPerWorker' not in kwds: kwds['threadsPerWorker'] = 30 if 'memoryPerWorkerMB' not in kwds: kwds['memoryPerWorkerMB'] = 40000 return InMemorySimulationExecutorFactory.create_executor(s3Service=s3, **kwds)
def evaluateWithExecutor(self, func, *args, **kwds): shouldClose = True if 'executor' in kwds: executor = kwds['executor'] shouldClose = False else: executor = InMemorySimulationExecutorFactory.create_executor() try: func_proxy = executor.define(func).result() args_proxy = [executor.define(a).result() for a in args] res_proxy = func_proxy(*args_proxy).result() result = res_proxy.toLocal().result() return result except Exception as ex: raise ex finally: if shouldClose: executor.close()
def create_executor(self): return InMemorySimulationExecutorFactory.create_executor()