changeset 31958:de5c9d0e02ea

atexit: switch to home-grown implementation
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 11 Apr 2017 14:54:12 -0700
parents 84f9eb9758c0
children b445a3f00528
files contrib/memory.py mercurial/dispatch.py mercurial/ui.py
diffstat 3 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/memory.py	Tue Apr 11 14:54:12 2017 -0700
+++ b/contrib/memory.py	Tue Apr 11 14:54:12 2017 -0700
@@ -12,7 +12,6 @@
 '''
 
 from __future__ import absolute_import
-import atexit
 
 def memusage(ui):
     """Report memory usage of the current process."""
@@ -29,4 +28,4 @@
                             for k, v in result.iteritems()]) + "\n")
 
 def extsetup(ui):
-    atexit.register(memusage, ui)
+    ui.atexit(memusage, ui)
--- a/mercurial/dispatch.py	Tue Apr 11 14:54:12 2017 -0700
+++ b/mercurial/dispatch.py	Tue Apr 11 14:54:12 2017 -0700
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import, print_function
 
-import atexit
 import difflib
 import errno
 import getopt
@@ -767,7 +766,7 @@
                 ui.warn(
                     _("time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
                     (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
-            atexit.register(print_time)
+            ui.atexit(print_time)
 
         if options['verbose'] or options['debug'] or options['quiet']:
             for opt in ('verbose', 'debug', 'quiet'):
--- a/mercurial/ui.py	Tue Apr 11 14:54:12 2017 -0700
+++ b/mercurial/ui.py	Tue Apr 11 14:54:12 2017 -0700
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import
 
-import atexit
 import collections
 import contextlib
 import errno
@@ -937,7 +936,7 @@
         if self._isatty(util.stderr):
             os.dup2(pager.stdin.fileno(), util.stderr.fileno())
 
-        @atexit.register
+        @self.atexit
         def killpager():
             if util.safehasattr(signal, "SIGINT"):
                 signal.signal(signal.SIGINT, signal.SIG_IGN)