~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Martin Pool
  • Date: 2010-02-10 00:31:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5025.
  • Revision ID: mbp@canonical.com-20100210003124-p1ye775wsg0okrfx
Add bzrlib.initialize

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
501
501
    """Report an exception that probably indicates a bug in bzr"""
502
502
    from bzrlib.crash import report_bug
503
503
    report_bug(exc_info, err_file)
 
504
 
 
505
 
 
506
def _flush_stdout_stderr():
 
507
    # installed into an atexit hook by bzrlib.initialize()
 
508
    try:
 
509
        sys.stdout.flush()
 
510
        sys.stderr.flush()
 
511
    except IOError, e:
 
512
        import errno
 
513
        if e.errno in [errno.EINVAL, errno.EPIPE]:
 
514
            pass
 
515
        else:
 
516
            raise
 
517
 
 
518
 
 
519
def _flush_trace():
 
520
    # run from atexit hook
 
521
    global _trace_file
 
522
    if _trace_file:
 
523
        _trace_file.flush()