该函数有个env参数,若果env=None, 则意味着继承父进程的环境变量,否则使用env作为环境变量,需要注意的是, 当env!=None时,则必须为映射类型,且映射值不能为int类型,也不能为None, ,否则报如下错误:
File "test_local_hadooop_runner.py", line 85, in test_local_hadoop_runner
task_runner.exec_task()
File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/local_runner.py", line 78, in exec_task
returncode = self.exec_cmd(self.entry, self.env_info)
File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 211, in exec_cmd
p = subprocess.Popen(cmd, shell=shell, env=env_info)
File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 1624, in _execute_child
env_list.append(k + b'=' + os.fsencode(v))
File "/home/vis/tools/python3.8/lib/python3.8/os.py", line 804, in fsencode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not int.
Traceback (most recent call last):
File "/home/vis/tools/python3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/home/vis/tools/python3.8/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "test_local_hadooop_runner.py", line 82, in kill_task
self.task_runner.kill_task()
File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 147, in kill_task
self.kill_hadoop()
File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 188, in kill_hadoop
returncode = self.exec_cmd(kill_hadoop, self.env_info, type="kill_hadoop")
File "/home/vis/personal_code/driver-python3/test/../driver_python3/runners/runner.py", line 218, in exec_cmd
p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/home/vis/tools/python3.8/lib/python3.8/subprocess.py", line 1624, in _execute_child
env_list.append(k + b'=' + os.fsencode(v))
File "/home/vis/tools/python3.8/lib/python3.8/os.py", line 804, in fsencode
filename = fspath(filename) # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType