| OLD | NEW |
| 1 # subprocess - Subprocesses with accessible I/O streams | 1 # subprocess - Subprocesses with accessible I/O streams |
| 2 # | 2 # |
| 3 # For more information about this module, see PEP 324. | 3 # For more information about this module, see PEP 324. |
| 4 # | 4 # |
| 5 # Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se> | 5 # Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se> |
| 6 # | 6 # |
| 7 # Licensed to PSF under a Contributor Agreement. | 7 # Licensed to PSF under a Contributor Agreement. |
| 8 # See http://www.python.org/2.4/license for licensing details. | 8 # See http://www.python.org/2.4/license for licensing details. |
| 9 | 9 |
| 10 r"""subprocess - Subprocesses with accessible I/O streams | 10 r"""subprocess - Subprocesses with accessible I/O streams |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 def __enter__(self): | 789 def __enter__(self): |
| 790 return self | 790 return self |
| 791 | 791 |
| 792 def __exit__(self, type, value, traceback): | 792 def __exit__(self, type, value, traceback): |
| 793 if self.stdout: | 793 if self.stdout: |
| 794 self.stdout.close() | 794 self.stdout.close() |
| 795 if self.stderr: | 795 if self.stderr: |
| 796 self.stderr.close() | 796 self.stderr.close() |
| 797 if self.stdin: | 797 if self.stdin: |
| 798 self.stdin.close() | 798 self.stdin.close() |
| 799 # Wait for the process to terminate, to avoid zombies. |
| 800 self.wait() |
| 799 | 801 |
| 800 def __del__(self, _maxsize=sys.maxsize, _active=_active): | 802 def __del__(self, _maxsize=sys.maxsize, _active=_active): |
| 801 if not self._child_created: | 803 if not self._child_created: |
| 802 # We didn't get to successfully create a child process. | 804 # We didn't get to successfully create a child process. |
| 803 return | 805 return |
| 804 # In case the child hasn't been waited on, check if it's done. | 806 # In case the child hasn't been waited on, check if it's done. |
| 805 self._internal_poll(_deadstate=_maxsize) | 807 self._internal_poll(_deadstate=_maxsize) |
| 806 if self.returncode is None and _active is not None: | 808 if self.returncode is None and _active is not None: |
| 807 # Child is still running, keep us alive until we can wait on it. | 809 # Child is still running, keep us alive until we can wait on it. |
| 808 _active.append(self) | 810 _active.append(self) |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 | 1753 |
| 1752 def terminate(self): | 1754 def terminate(self): |
| 1753 """Terminate the process with SIGTERM | 1755 """Terminate the process with SIGTERM |
| 1754 """ | 1756 """ |
| 1755 self.send_signal(signal.SIGTERM) | 1757 self.send_signal(signal.SIGTERM) |
| 1756 | 1758 |
| 1757 def kill(self): | 1759 def kill(self): |
| 1758 """Kill the process with SIGKILL | 1760 """Kill the process with SIGKILL |
| 1759 """ | 1761 """ |
| 1760 self.send_signal(signal.SIGKILL) | 1762 self.send_signal(signal.SIGKILL) |
| OLD | NEW |