Add a function to be called before reloading the process. Note that for open file and socket handles it is generally preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or `os.set_inheritable`) instead of using a reload hook to close them.
(fn: Callable[[], None])
| 150 | |
| 151 | |
| 152 | def add_reload_hook(fn: Callable[[], None]) -> None: |
| 153 | """Add a function to be called before reloading the process. |
| 154 | |
| 155 | Note that for open file and socket handles it is generally |
| 156 | preferable to set the ``FD_CLOEXEC`` flag (using `fcntl` or |
| 157 | `os.set_inheritable`) instead of using a reload hook to close them. |
| 158 | """ |
| 159 | _reload_hooks.append(fn) |
| 160 | |
| 161 | |
| 162 | def _reload_on_update(modify_times: Dict[str, float]) -> None: |