Kill the current running process and cleanup. Note ---- The worker can start a new process when send is called again.
(self)
| 126 | pass |
| 127 | |
| 128 | def kill(self): |
| 129 | """Kill the current running process and cleanup. |
| 130 | |
| 131 | Note |
| 132 | ---- |
| 133 | The worker can start a new process when send is called again. |
| 134 | """ |
| 135 | if self._proc is not None: |
| 136 | # allow gracefully shutdown |
| 137 | try: |
| 138 | self._writer.close() |
| 139 | except OSError: |
| 140 | pass |
| 141 | try: |
| 142 | self._reader.close() |
| 143 | except OSError: |
| 144 | pass |
| 145 | # kill all child processes recursively |
| 146 | try: |
| 147 | kill_child_processes(self._proc.pid) |
| 148 | except TypeError: |
| 149 | pass |
| 150 | try: |
| 151 | self._proc.kill() |
| 152 | except OSError: |
| 153 | pass |
| 154 | |
| 155 | # Join the child process to avoid zombie processes |
| 156 | self.join(timeout=1.0) |
| 157 | self._proc = None |
| 158 | self._remaining_uses = None |
| 159 | |
| 160 | def _start(self): |
| 161 | """Start a new subprocess if nothing is available""" |