diff options
| author | Alan Conway <aconway@apache.org> | 2010-08-04 15:46:20 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2010-08-04 15:46:20 +0000 |
| commit | ff346c19aa68b458eabde29c6a3fbfb24a0fd378 (patch) | |
| tree | 09503f1b1963b7e2fcf449656d58844f6748bac1 /qpid/python | |
| parent | dd9036ce5d0ca2cf529040f4ef583f108eab2767 (diff) | |
| download | qpid-python-ff346c19aa68b458eabde29c6a3fbfb24a0fd378.tar.gz | |
Fix race conditions in brokertest.py and cluster_tests.py.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@982309 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rw-r--r-- | qpid/python/qpid/brokertest.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/qpid/python/qpid/brokertest.py b/qpid/python/qpid/brokertest.py index a241c8b528..19acfd76ca 100644 --- a/qpid/python/qpid/brokertest.py +++ b/qpid/python/qpid/brokertest.py @@ -148,6 +148,7 @@ class Popen(popen2.Popen3): drain - if true (default) drain stdout/stderr to files. """ self._clean = False + self._clean_lock = Lock() assert find_exe(cmd[0]), "executable not found: "+cmd[0] if type(cmd) is type(""): cmd = [cmd] # Make it a list. self.cmd = [ str(x) for x in cmd ] @@ -174,12 +175,15 @@ class Popen(popen2.Popen3): def _cleanup(self): """Close pipes to sub-process""" - if self._clean: return - self._clean = True - self.stdin.close() - self.drain() # Drain output pipes. - self.stdout.thread.join() # Drain thread closes pipe. - self.stderr.thread.join() + self._clean_lock.acquire() + try: + if self._clean: return + self._clean = True + self.stdin.close() + self.drain() # Drain output pipes. + self.stdout.thread.join() # Drain thread closes pipe. + self.stderr.thread.join() + finally: self._clean_lock.release() def unexpected(self,msg): self._cleanup() |
