From: Martin Quinson Date: Tue, 1 Jan 2019 10:22:21 +0000 (+0100) Subject: tesh: try harder to not loose the cwd between threads X-Git-Tag: v3_22~725 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6c351ec3b051af44fadac0fabbc5b57318079795?hp=9b23aedfbbfcbe7dfcc01daec713ebc103a44afd tesh: try harder to not loose the cwd between threads --- diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index b75ab27e84..5ba29b81e3 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -188,7 +188,7 @@ class TeshState(Singleton): t.acquire() t.release() -#Command line object +# Command line object class Cmd(object): def __init__(self): self.input_pipe = [] @@ -199,7 +199,8 @@ class Cmd(object): self.linenumber = -1 self.background = False - self.cwd = None + # Python threads loose the cwd + self.cwd = os.getcwd() self.ignore_output = False self.expect_return = 0 @@ -259,8 +260,6 @@ class Cmd(object): def run_if_possible(self): if self.can_run(): if self.background: - #Python threads loose the cwd - self.cwd = os.getcwd() lock = _thread.allocate_lock() lock.acquire() TeshState().add_thread(lock) @@ -273,10 +272,8 @@ class Cmd(object): def _run(self, lock=None): - #Python threads loose the cwd - if self.cwd is not None: - os.chdir(self.cwd) - self.cwd = None + # Python threads loose the cwd + os.chdir(self.cwd) #retrocompatibility: support ${aaa:=.} variable format def replace_perl_variables(m):