-
Notifications
You must be signed in to change notification settings - Fork 154
Description
In the LocalJob class, which inherits from threading.Thread, the run() method uses os.chdir() to change the working directory before launching a background process, and then changes it back in a finally block
os.chdir(self.execution_dir)
self._process = subprocess.Popen(
self.command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
encoding="utf-8",
bufsize=1,
env=self.env,
)
If multiple LocalJob threads run concurrently, they will mix up each other's working directories, leading to chaotic path-resolution failures.
So instead of changing the path using the os.chdir(), can't we provide the path as an argument for the subprocess creation time? since this prevents changing the main process's path.
self._process = subprocess.Popen(
self.command,
cwd=self.execution_dir,
......
)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels