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 /demoscript | |
parent | Ubuntu package updates (diff) | |
download | ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.tar.bz2 ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.tar.xz ice-93fe084d8136d8e2649f20a6bc5c4627445aedc4.zip |
ICE-5904 - Fix IceStorm/replicated failure
Diffstat (limited to 'demoscript')
-rw-r--r-- | demoscript/Util.py | 21 |
1 files changed, 13 insertions, 8 deletions
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 |