changeset 42474:adb636392b3f

demandimport: add tracing coverage for Python 3 This makes things feel a little less mysterious when modules are being imported. Differential Revision: https://phab.mercurial-scm.org/D6523
author Augie Fackler <augie@google.com>
date Wed, 12 Jun 2019 16:08:21 -0400
parents 307f67d4aee3
children ff562d711919
files hgdemandimport/demandimportpy3.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgdemandimport/demandimportpy3.py	Fri Jun 14 10:21:47 2019 -0700
+++ b/hgdemandimport/demandimportpy3.py	Wed Jun 12 16:08:21 2019 -0400
@@ -32,6 +32,8 @@
 import importlib.util
 import sys
 
+from . import tracing
+
 _deactivated = False
 
 class _lazyloaderex(importlib.util.LazyLoader):
@@ -40,10 +42,11 @@
     """
     def exec_module(self, module):
         """Make the module load lazily."""
-        if _deactivated or module.__name__ in ignores:
-            self.loader.exec_module(module)
-        else:
-            super().exec_module(module)
+        with tracing.log('demandimport %s', module):
+            if _deactivated or module.__name__ in ignores:
+                self.loader.exec_module(module)
+            else:
+                super().exec_module(module)
 
 # This is 3.6+ because with Python 3.5 it isn't possible to lazily load
 # extensions. See the discussion in https://bugs.python.org/issue26186 for more.