summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-07-27 15:25:17 +0200
committerSebastien Martini <seb@dbzteam.org>2010-07-27 15:25:17 +0200
commit3fb456af85bdf73ae38b00ebc16a16777a858321 (patch)
treebbd853b64bfa2670a233c2381b9795fe10212b0f
parent817169ec933de0eaf0d98793ade01a89aabcc4ce (diff)
downloadpyinotify-3fb456af85bdf73ae38b00ebc16a16777a858321.tar.gz
Flush stdout stream immediately after events or stats are written
(idea submitted by hv@tbz-pariv.de).
-rwxr-xr-xpython2/pyinotify.py8
-rwxr-xr-xpython3/pyinotify.py8
2 files changed, 12 insertions, 4 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index 2bf9aea..430c467 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -882,6 +882,7 @@ class PrintAllEvents(ProcessEvent):
"""
self._out.write(str(event))
self._out.write('\n')
+ self._out.flush()
class ChainIfTrue(ProcessEvent):
@@ -2142,8 +2143,11 @@ def command_line():
cb_fun = None
if options.stats:
def cb(s):
- print('%s\n%s\n' % (repr(s.proc_fun()),
- s.proc_fun()))
+ sys.stdout.write(repr(s.proc_fun()))
+ sys.stdout.write('\n')
+ sys.stdout.write(str(s.proc_fun()))
+ sys.stdout.write('\n')
+ sys.stdout.flush()
cb_fun = cb
log.debug('Start monitoring %s, (press c^c to halt pyinotify)' % path)
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index 2d8fa03..6edd780 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -837,6 +837,7 @@ class PrintAllEvents(ProcessEvent):
"""
self._out.write(str(event))
self._out.write('\n')
+ self._out.flush()
class ChainIfTrue(ProcessEvent):
@@ -2095,8 +2096,11 @@ def command_line():
cb_fun = None
if options.stats:
def cb(s):
- print('%s\n%s\n' % (repr(s.proc_fun()),
- s.proc_fun()))
+ sys.stdout.write(repr(s.proc_fun()))
+ sys.stdout.write('\n')
+ sys.stdout.write(str(s.proc_fun()))
+ sys.stdout.write('\n')
+ sys.stdout.flush()
cb_fun = cb
log.debug('Start monitoring %s, (press c^c to halt pyinotify)' % path)