changeset 32926:661025fd3e1c

highlight: put pygments import inside demandimport.deactivated I tripped on some weirdness relating to _thread vs threading way down in a dep of highlight recently. I'm not really sure why I'm only just seeing this defect now, but experimentally this fixes the problem, and shouldn't cause any load-time slowness for people until pygments is actually about to be used since highlight.highlight is still lazily loaded in the highlight/__init__.py file.
author Augie Fackler <raf@durin42.com>
date Sun, 18 Jun 2017 23:05:54 -0400
parents bd77ac2bd23a
children 89610c586fa2
files hgext/highlight/highlight.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/highlight/highlight.py	Sun Jun 18 22:19:54 2017 -0400
+++ b/hgext/highlight/highlight.py	Sun Jun 18 23:05:54 2017 -0400
@@ -10,11 +10,6 @@
 
 from __future__ import absolute_import
 
-import pygments
-import pygments.formatters
-import pygments.lexers
-import pygments.util
-
 from mercurial import demandimport
 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__'])
 
@@ -23,6 +18,12 @@
     util,
 )
 
+with demandimport.deactivated():
+    import pygments
+    import pygments.formatters
+    import pygments.lexers
+    import pygments.util
+
 highlight = pygments.highlight
 ClassNotFound = pygments.util.ClassNotFound
 guess_lexer = pygments.lexers.guess_lexer