| 342 | self.started = True |
| 343 | |
| 344 | def stop(self): |
| 345 | if self.proc: |
| 346 | try: |
| 347 | logger.info("proc.terminate with pid %s", self.proc.pid) |
| 348 | self.proc.terminate() |
| 349 | if self.tmp_app_path and os.path.exists(self.tmp_app_path): |
| 350 | logger.debug("removing temporary app path %s", self.tmp_app_path) |
| 351 | shutil.rmtree(self.tmp_app_path) |
| 352 | |
| 353 | self.proc.communicate( |
| 354 | timeout=self.stop_timeout # pylint: disable=unexpected-keyword-arg |
| 355 | ) |
| 356 | except subprocess.TimeoutExpired: |
| 357 | logger.exception( |
| 358 | "subprocess terminate not success, trying to kill " |
| 359 | "the subprocess in a safe manner" |
| 360 | ) |
| 361 | self.proc.kill() |
| 362 | self.proc.communicate() |
| 363 | logger.info("process stop completes!") |
| 364 | |
| 365 | |
| 366 | class RRunner(ProcessRunner): |