def _execute(self, ctx):
self._check_closed()
# Temporary file used to pass arguments to the started subprocess
file_descriptor, arguments_json_path = tempfile.mkstemp(prefix='executor-', suffix='.json')
os.close(file_descriptor)
with open(arguments_json_path, 'wb') as f:
f.write(pickle.dumps(self._create_arguments_dict(ctx)))
env = self._construct_subprocess_env(task=ctx.task)
# Asynchronously start the operation in a subprocess
proc = subprocess.Popen(
[
sys.executable,
os.path.expanduser(os.path.expandvars(__file__)),
os.path.expanduser(os.path.expandvars(arguments_json_path))
],
env=env)
self._tasks[ctx.task.id] = _Task(ctx=ctx, proc=proc)
评论列表
文章目录