Cache the modification times of any modules imported in this execution and track imports
(self)
| 854 | pass |
| 855 | |
| 856 | def post_execute_hook(self): |
| 857 | """Cache the modification times of any modules imported in this execution and track imports""" |
| 858 | |
| 859 | # Track imports from the recently executed code if autoreload 3 is enabled |
| 860 | if self._reloader.enabled and self._reloader.autoload_obj: |
| 861 | # Use the stored execution info |
| 862 | if ( |
| 863 | hasattr(self, "_last_execution_info") |
| 864 | and self._last_execution_info |
| 865 | and self._last_execution_info.transformed_cell |
| 866 | ): |
| 867 | self._track_imports_from_code( |
| 868 | self._last_execution_info.transformed_cell |
| 869 | ) |
| 870 | |
| 871 | newly_loaded_modules = set(sys.modules) - self.loaded_modules |
| 872 | for modname in newly_loaded_modules: |
| 873 | _, pymtime = self._reloader.filename_and_mtime(sys.modules[modname]) |
| 874 | if pymtime is not None: |
| 875 | self._reloader.modules_mtimes[modname] = pymtime |
| 876 | |
| 877 | self.loaded_modules.update(newly_loaded_modules) |
| 878 | |
| 879 | def _track_imports_from_code(self, code: str) -> None: |
| 880 | """Track import statements from executed code""" |