~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Karl Bielefeldt
  • Date: 2010-10-05 23:30:18 UTC
  • mto: (5483.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5484.
  • Revision ID: 7mq3cbbd9q@snkmail.com-20101005233018-cl7ie97p4qlvjaan
Fix Python 2.4 incompatibilities

Show diffs side-by-side

added added

removed removed

Lines of Context:
472
472
 
473
473
def _dump_memory_usage(err_file):
474
474
    try:
475
 
        fd, name = tempfile.mkstemp(prefix="bzr_memdump", suffix=".json")
476
 
        dump_file = os.fdopen(fd, 'w')
477
 
        from meliae import scanner
478
 
        scanner.dump_gc_objects(dump_file)
479
 
        err_file.write("Memory dumped to %s\n" % name)
480
 
    except ImportError:
481
 
        err_file.write("Dumping memory requires meliae module.\n")
482
 
        log_exception_quietly()
483
 
    except:
484
 
        err_file.write("Exception while dumping memory.\n")
485
 
        log_exception_quietly()
 
475
        try:
 
476
            fd, name = tempfile.mkstemp(prefix="bzr_memdump", suffix=".json")
 
477
            dump_file = os.fdopen(fd, 'w')
 
478
            from meliae import scanner
 
479
            scanner.dump_gc_objects(dump_file)
 
480
            err_file.write("Memory dumped to %s\n" % name)
 
481
        except ImportError:
 
482
            err_file.write("Dumping memory requires meliae module.\n")
 
483
            log_exception_quietly()
 
484
        except:
 
485
            err_file.write("Exception while dumping memory.\n")
 
486
            log_exception_quietly()
486
487
    finally:
487
 
        dump_file.close()
 
488
        if dump_file is not None:
 
489
            dump_file.close()
 
490
        elif fd is not None:
 
491
            os.close(fd)
488
492
 
489
493
def report_exception(exc_info, err_file):
490
494
    """Report an exception to err_file (typically stderr) and to .bzr.log.