Rev 4845: (mbp) remove extra buffer flushing on trace file in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Dec 1 05:35:56 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4845 [merge]
revision-id: pqm at pqm.ubuntu.com-20091201053552-yws5hsfrricui8b6
parent: pqm at pqm.ubuntu.com-20091201024020-8uqp6v8p2xqppu36
parent: mbp at sourcefrog.net-20091130060926-3e26u3qtibr1nolj
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-12-01 05:35:52 +0000
message:
(mbp) remove extra buffer flushing on trace file
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
=== modified file 'NEWS'
--- a/NEWS 2009-11-30 12:24:55 +0000
+++ b/NEWS 2009-12-01 05:35:52 +0000
@@ -182,6 +182,9 @@
* Shelve command refuse to run if there is no real terminal.
(Alexander Belchenko)
+* Avoid unnecessarily flushing of trace file; it's now unbuffered at the
+ Python level. (Martin Pool)
+
Documentation
*************
=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py 2009-11-19 20:47:51 +0000
+++ b/bzrlib/trace.py 2009-12-01 05:35:52 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -153,13 +153,11 @@
_bzr_logger.error(*args, **kwargs)
-_last_mutter_flush_time = None
-
-
def mutter(fmt, *args):
- global _last_mutter_flush_time
if _trace_file is None:
return
+ # XXX: Don't check this every time; instead anyone who closes the file
+ # ought to deregister it. We can tolerate None.
if (getattr(_trace_file, 'closed', None) is not None) and _trace_file.closed:
return
@@ -182,15 +180,7 @@
timestamp = '%0.3f ' % (now - _bzr_log_start_time,)
out = timestamp + out + '\n'
_trace_file.write(out)
- # We flush if we haven't flushed for a few seconds. We don't want to flush
- # on every mutter, but when a command takes a while, it can be nice to see
- # updates in the debug log.
- if (_last_mutter_flush_time is None
- or (now - _last_mutter_flush_time) > 2.0):
- flush = getattr(_trace_file, 'flush', None)
- if flush is not None:
- flush()
- _last_mutter_flush_time = now
+ # there's no explicit flushing; the file is typically line buffered.
def mutter_callsite(stacklevel, fmt, *args):
@@ -251,7 +241,7 @@
_bzr_log_filename = _get_bzr_log_filename()
_rollover_trace_maybe(_bzr_log_filename)
try:
- bzr_log_file = open(_bzr_log_filename, 'at', 1) # line buffered
+ bzr_log_file = open(_bzr_log_filename, 'at', buffering=0) # unbuffered
# bzr_log_file.tell() on windows always return 0 until some writing done
bzr_log_file.write('\n')
if bzr_log_file.tell() <= 2:
More information about the bazaar-commits
mailing list