From 1b32d374b5033243c154a471893557c60c50d9c2 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Mon, 6 Dec 2010 13:19:31 +0100 Subject: [PATCH] Import cProfile module before falling back to profile the cProfile/profile modules are great for performance debugging. The pure-python profile module has much more overhead though and the cProfile module is recommended if it exists. This changes to import to first try the cProfile module and then fall back to the profile module. The cProfile/profiles modules are API compatible for all that its worth... If that does not exist we continue to complain as before. Signed-off-by: Sebastian Spaeth Signed-off-by: Nicolas Sebrecht --- offlineimap/threadutil.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offlineimap/threadutil.py b/offlineimap/threadutil.py index c64734b..da7bcf6 100644 --- a/offlineimap/threadutil.py +++ b/offlineimap/threadutil.py @@ -157,7 +157,10 @@ class ExitNotifyThread(Thread): if not profiledir: # normal case Thread.run(self) else: - import profile + try: + import cProfile as profile + except ImportError: + import profile prof = profile.Profile() try: prof = prof.runctx("Thread.run(self)", globals(), locals())