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)
| 3750 | # Things related to IPython exiting |
| 3751 | #------------------------------------------------------------------------- |
| 3752 | def atexit_operations(self): |
| 3753 | """This will be executed at the time of exit. |
| 3754 | |
| 3755 | Cleanup operations and saving of persistent data that is done |
| 3756 | unconditionally by IPython should be performed here. |
| 3757 | |
| 3758 | For things that may depend on startup flags or platform specifics (such |
| 3759 | as having readline or not), register a separate atexit function in the |
| 3760 | code that has the appropriate information, rather than trying to |
| 3761 | clutter |
| 3762 | """ |
| 3763 | # Close the history session (this stores the end time and line count) |
| 3764 | # this must be *before* the tempfile cleanup, in case of temporary |
| 3765 | # history db |
| 3766 | self.history_manager.end_session() |
| 3767 | |
| 3768 | # Cleanup all tempfiles and folders left around |
| 3769 | for tfile in self.tempfiles: |
| 3770 | try: |
| 3771 | os.unlink(tfile) |
| 3772 | except OSError: |
| 3773 | pass |
| 3774 | |
| 3775 | for tdir in self.tempdirs: |
| 3776 | try: |
| 3777 | os.rmdir(tdir) |
| 3778 | except OSError: |
| 3779 | pass |
| 3780 | |
| 3781 | # Clear all user namespaces to release all references cleanly. |
| 3782 | self.reset(new_session=False) |
| 3783 | |
| 3784 | # Run user hooks |
| 3785 | self.hooks.shutdown_hook() |
| 3786 | |
| 3787 | def cleanup(self): |
| 3788 | self.restore_sys_module_state() |
nothing calls this directly
no test coverage detected