/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2010-03-11 18:00:23 UTC
  • mfrom: (5085 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5086.
  • Revision ID: jelmer@samba.org-20100311180023-tps53ljemi1enebg
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1671
1671
                unicodestr = log_contents.decode('utf8', 'replace')
1672
1672
                log_contents = unicodestr.encode('utf8')
1673
1673
            if not keep_log_file:
1674
 
                self._log_file.close()
 
1674
                close_attempts = 0
 
1675
                max_close_attempts = 100
 
1676
                first_close_error = None
 
1677
                while close_attempts < max_close_attempts:
 
1678
                    close_attempts += 1
 
1679
                    try:
 
1680
                        self._log_file.close()
 
1681
                    except IOError, ioe:
 
1682
                        if ioe.errno is None:
 
1683
                            # No errno implies 'close() called during
 
1684
                            # concurrent operation on the same file object', so
 
1685
                            # retry.  Probably a thread is trying to write to
 
1686
                            # the log file.
 
1687
                            if first_close_error is None:
 
1688
                                first_close_error = ioe
 
1689
                            continue
 
1690
                        raise
 
1691
                    else:
 
1692
                        break
 
1693
                if close_attempts > 1:
 
1694
                    sys.stderr.write(
 
1695
                        'Unable to close log file on first attempt, '
 
1696
                        'will retry: %s\n' % (first_close_error,))
 
1697
                    if close_attempts == max_close_attempts:
 
1698
                        sys.stderr.write(
 
1699
                            'Unable to close log file after %d attempts.\n'
 
1700
                            % (max_close_attempts,))
1675
1701
                self._log_file = None
1676
1702
                # Permit multiple calls to get_log until we clean it up in
1677
1703
                # finishLogFile