| OLD | NEW |
| 1 # Copyright 2009 Google Inc. All Rights Reserved. | 1 # Copyright 2009 Google Inc. All Rights Reserved. |
| 2 # | 2 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 3 # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 # you may not use this file except in compliance with the License. | 4 # you may not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 5 # You may obtain a copy of the License at |
| 6 # | 6 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 7 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 8 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 9 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 10 # distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 self.lock = threading.Lock() | 291 self.lock = threading.Lock() |
| 292 self.stdout = stdout | 292 self.stdout = stdout |
| 293 self.delay = delay | 293 self.delay = delay |
| 294 self.last_flushed_at = time.time() | 294 self.last_flushed_at = time.time() |
| 295 self.stdout.flush() | 295 self.stdout.flush() |
| 296 | 296 |
| 297 def write(self, out): | 297 def write(self, out): |
| 298 """Thread-safe.""" | 298 """Thread-safe.""" |
| 299 self.stdout.write(out) | 299 self.stdout.write(out) |
| 300 should_flush = False | 300 should_flush = False |
| 301 with self.lock: | 301 self.lock.acquire() |
| 302 try: |
| 302 if (time.time() - self.last_flushed_at) > self.delay: | 303 if (time.time() - self.last_flushed_at) > self.delay: |
| 303 should_flush = True | 304 should_flush = True |
| 304 self.last_flushed_at = time.time() | 305 self.last_flushed_at = time.time() |
| 306 finally: |
| 307 self.lock.release() |
| 305 if should_flush: | 308 if should_flush: |
| 306 self.stdout.flush() | 309 self.stdout.flush() |
| 307 | 310 |
| 308 def flush(self): | 311 def flush(self): |
| 309 self.stdout.flush() | 312 self.stdout.flush() |
| 310 | 313 |
| 311 | 314 |
| 312 def CheckCallAndFilter(args, stdout=None, filter_fn=None, | 315 def CheckCallAndFilter(args, stdout=None, filter_fn=None, |
| 313 print_stdout=None, call_filter_on_first_line=False, | 316 print_stdout=None, call_filter_on_first_line=False, |
| 314 **kwargs): | 317 **kwargs): |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 if exception: | 584 if exception: |
| 582 self.parent.exceptions.append(exception) | 585 self.parent.exceptions.append(exception) |
| 583 if self.parent.progress: | 586 if self.parent.progress: |
| 584 self.parent.progress.update(1) | 587 self.parent.progress.update(1) |
| 585 assert not self.item.name in self.parent.ran | 588 assert not self.item.name in self.parent.ran |
| 586 if not self.item.name in self.parent.ran: | 589 if not self.item.name in self.parent.ran: |
| 587 self.parent.ran.append(self.item.name) | 590 self.parent.ran.append(self.item.name) |
| 588 finally: | 591 finally: |
| 589 self.parent.ready_cond.notifyAll() | 592 self.parent.ready_cond.notifyAll() |
| 590 self.parent.ready_cond.release() | 593 self.parent.ready_cond.release() |
| OLD | NEW |