Kill all child processes recursively for a given pid. Parameters ---------- pid : int The given parameter id.
(pid)
| 155 | |
| 156 | |
| 157 | def _kill_child_processes(pid): |
| 158 | """Kill all child processes recursively for a given pid. |
| 159 | |
| 160 | Parameters |
| 161 | ---------- |
| 162 | pid : int |
| 163 | The given parameter id. |
| 164 | """ |
| 165 | import psutil # pylint: disable=import-outside-toplevel |
| 166 | |
| 167 | try: |
| 168 | parent = psutil.Process(pid) |
| 169 | children = parent.children(recursive=True) |
| 170 | except psutil.NoSuchProcess: |
| 171 | return |
| 172 | |
| 173 | for process in children: |
| 174 | try: |
| 175 | process.kill() |
| 176 | except psutil.NoSuchProcess: |
| 177 | pass |
| 178 | |
| 179 | |
| 180 | @register_global_func("runtime.disco.create_process_pool") |