MCPcopy Index your code
hub / github.com/ipython/ipython / atexit_operations

Method atexit_operations

IPython/core/interactiveshell.py:4111–4143  ·  view source on GitHub ↗

This will be executed at the time of exit. Cleanup operations and saving of persistent data that is done unconditionally by IPython should be performed here. For things that may depend on startup flags or platform specifics (such as having readline or not), register

(self)

Source from the content-addressed store, hash-verified

4109 # Things related to IPython exiting
4110 #-------------------------------------------------------------------------
4111 def atexit_operations(self):
4112 """This will be executed at the time of exit.
4113
4114 Cleanup operations and saving of persistent data that is done
4115 unconditionally by IPython should be performed here.
4116
4117 For things that may depend on startup flags or platform specifics (such
4118 as having readline or not), register a separate atexit function in the
4119 code that has the appropriate information, rather than trying to
4120 clutter
4121 """
4122 self._atexit_once()
4123
4124 # Cleanup all tempfiles and folders left around
4125 for tfile in self.tempfiles:
4126 try:
4127 tfile.unlink()
4128 self.tempfiles.remove(tfile)
4129 except FileNotFoundError:
4130 pass
4131 del self.tempfiles
4132 for tdir in self.tempdirs:
4133 try:
4134 shutil.rmtree(tdir)
4135 self.tempdirs.remove(tdir)
4136 except FileNotFoundError:
4137 pass
4138 del self.tempdirs
4139
4140 # Restore user's cursor
4141 if hasattr(self, "editing_mode") and self.editing_mode == "vi":
4142 sys.stdout.write("\x1b[0 q")
4143 sys.stdout.flush()
4144
4145 def cleanup(self):
4146 self.restore_sys_module_state()

Callers

nothing calls this directly

Calls 4

_atexit_onceMethod · 0.95
removeMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected