Recursively reload all modules used in the given module. Optionally takes a list of modules to exclude from reloading. The default exclude list contains modules listed in sys.builtin_module_names with additional sys, os.path, builtins and __main__, to prevent, e.g., resetting displ
(
module,
exclude=(
*sys.builtin_module_names,
"sys",
"os.path",
"builtins",
"__main__",
"numpy",
"numpy._globals",
),
)
| 283 | |
| 284 | # Replacement for reload() |
| 285 | def reload( |
| 286 | module, |
| 287 | exclude=( |
| 288 | *sys.builtin_module_names, |
| 289 | "sys", |
| 290 | "os.path", |
| 291 | "builtins", |
| 292 | "__main__", |
| 293 | "numpy", |
| 294 | "numpy._globals", |
| 295 | ), |
| 296 | ): |
| 297 | """Recursively reload all modules used in the given module. Optionally |
| 298 | takes a list of modules to exclude from reloading. The default exclude |
| 299 | list contains modules listed in sys.builtin_module_names with additional |
| 300 | sys, os.path, builtins and __main__, to prevent, e.g., resetting |
| 301 | display, exception, and io hooks. |
| 302 | """ |
| 303 | global found_now |
| 304 | for i in exclude: |
| 305 | found_now[i] = 1 |
| 306 | try: |
| 307 | with replace_import_hook(deep_import_hook): |
| 308 | return deep_reload_hook(module) |
| 309 | finally: |
| 310 | found_now = {} |
searching dependent graphs…