diff options
author | Joe George <joe@zeroc.com> | 2014-11-16 20:05:08 -0500 |
---|---|---|
committer | Joe George <joe@zeroc.com> | 2014-11-16 20:05:52 -0500 |
commit | 93fe084d8136d8e2649f20a6bc5c4627445aedc4 (patch) | |
tree | a40b03c04c61d403db6b3445629415eb0145e595 | |
parent | Ubuntu package updates (diff) | |
download | ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.tar.bz2 ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.tar.xz ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.zip |
ICE-5904 - Fix IceStorm/replicated failure
-rwxr-xr-x | cpp/demo/IceStorm/replicated/expect.py | 10 | ||||
-rw-r--r-- | demoscript/Util.py | 21 | ||||
-rwxr-xr-x | scripts/Expect.py | 3 |
3 files changed, 24 insertions, 10 deletions
diff --git a/cpp/demo/IceStorm/replicated/expect.py b/cpp/demo/IceStorm/replicated/expect.py index a4f747223de..f6da746197a 100755 --- a/cpp/demo/IceStorm/replicated/expect.py +++ b/cpp/demo/IceStorm/replicated/expect.py @@ -43,6 +43,14 @@ Util.cleanDbDir("db/node") Util.cleanDbDir("db/registry") print("ok") +sys.stdout.write("cleaning old log files... ") +for f in ["db/DemoIceStorm-1.out", "db/DemoIceStorm-2.out", "db/DemoIceStorm-3.out"]: + try: + os.remove(f) + except: + pass +print("ok") + if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: @@ -92,6 +100,7 @@ time.sleep(3) sub.expect('[0-9][0-9]/[0-9][0-9].*\n[0-9][0-9]/[0-9][0-9]') print("ok") +sys.stdout.write("shutting down... ") sub.kill(signal.SIGINT) sub.waitTestSuccess() pub.kill(signal.SIGINT) @@ -116,3 +125,4 @@ admin.sendline('registry shutdown Master') admin.sendline('exit') admin.waitTestSuccess() node.waitTestSuccess() +print("ok") diff --git a/demoscript/Util.py b/demoscript/Util.py index efe9e2a467d..33d34f91d4d 100644 --- a/demoscript/Util.py +++ b/demoscript/Util.py @@ -90,15 +90,19 @@ class filereader(Expect.reader): Expect.reader.__init__(self, desc, p, None) def run(self): - + self.keepReading = True try: - while True: + while True and self.keepReading == True: c = self.p.read(1) if not c: time.sleep(0.1) + # Refresh position so we don't get stuck at EOF + # while the file is still being written + # (Does not happen in all Python versions) + self.p.seek(self.p.tell()) continue - if c == '\r': continue + if c == '\r':continue self.cv.acquire() try: # Depending on Python version and platform, the value c could be a @@ -110,11 +114,15 @@ class filereader(Expect.reader): self.cv.notify() finally: self.cv.release() + self.p.close() except ValueError as e: pass except IOError as e: print(e) + def stopReading(self): + self.keepReading = False; + class FileExpect(object): def __init__(self, path): @@ -124,7 +132,7 @@ class FileExpect(object): self.matchindex = 0 # the index of the matched pattern self.match = None # The last match - self.f = open(path) + self.f = open(path, 'r') self.r = filereader(path, self.f) # The thread is marked as a daemon thread. This is done so that if @@ -169,10 +177,7 @@ class FileExpect(object): return self.matchindex def terminate(self): - try: - self.f.close() - except: - pass + self.r.stopReading() self.r.join() self.r = None diff --git a/scripts/Expect.py b/scripts/Expect.py index 9b579aba63d..cb25a45cd70 100755 --- a/scripts/Expect.py +++ b/scripts/Expect.py @@ -163,8 +163,7 @@ class reader(threading.Thread): return buf def match(self, pattern, timeout, matchall = False): - """pattern is a list of string, regexp duples. - """ + # pattern is a list of string, regexp duples. if timeout is not None: end = time.time() + timeout |