Browse files

iostream._newbuffer starts auto-flush clock

This means that the timer runs between flush calls, rather than the previous logic where the timer started on the first print after each flush.  The problem with the previous logic was that it meant the first message after any flush could *never* be displayed immediately without an explicit manual `stdout.flush()`.

The disadvantage of the new approach is that most cells with two or more print statements will result in at least two stdout messages, because when used interactively the first print statement will ~always trigger the flush_timeout logic.
  • Loading branch information...
1 parent 144f08a commit e2e91f9bd659589a858e6489a748964fc9367164 @minrk committed Aug 24, 2012
Showing with 2 additions and 4 deletions.
  1. +2 −4 IPython/zmq/
@@ -78,9 +78,7 @@ def write(self, string):
current_time = time.time()
- if self._start <= 0:
- self._start = current_time
- elif current_time - self._start > self.flush_interval:
+ if current_time - self._start > self.flush_interval:
def writelines(self, sequence):
@@ -92,4 +90,4 @@ def writelines(self, sequence):
def _new_buffer(self):
self._buffer = StringIO()
- self._start = -1
+ self._start = time.time()

0 comments on commit e2e91f9

Please sign in to comment.