[merge] don't force gc from bzr script

Martin Pool mbp at canonical.com
Mon Mar 17 02:25:56 GMT 2008


annotate says that Andrew recently added a gc call into the bzr
script.  I can't find the review thread about it (though there
probably was one).

Maybe this was just done to help him in debugging, and not intended to
be merged?  I don't think we should keep it permanently because, as
the comment above this paragraph says, it's measurably faster to skip
garbage collection, and as it's not reliable we can't actually use it
for any cleanup.

=== modified file 'bzr'
*** bzr 2008-03-16 14:01:20 +0000
--- bzr 2008-03-17 02:23:39 +0000
***************
*** 110,133 ****

      # By this point we really have completed everything we want to do, and
      # there's no point doing any additional cleanup.  Abruptly exiting here
      # stops any background threads getting into trouble as code is unloaded,
      # and it may also be slightly faster, through avoiding gc of objects that
      # are just about to be discarded anyhow.  This does mean that atexit hooks
      # won't run but we don't use them.  Also file buffers won't be flushed,
      # but our policy is to always close files from a finally block.
-- mbp 20070215
      try:
          sys.stdout.flush()
          sys.stderr.flush()
      except IOError, e:
          import errno
          if e.errno in [errno.EINVAL, errno.EPIPE]:
              pass
          else:
              raise
      if bzrlib.trace._trace_file:
          # this is also _bzr_log
          bzrlib.trace._trace_file.flush()
-     import gc; gc.collect()
      os._exit(exit_val)
  else:
      pass    # should this give an error? - it can't be used as a lib


-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list