Mercurial > ~astiob > upreckon > hgweb
diff win32.py @ 134:e84f33a60a5c
Moved process killing logic into platform-specific modules
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 20 May 2011 14:47:42 +0100 |
parents | 7923faf392fe |
children | 388ae061c915 |
line wrap: on
line diff
--- a/win32.py Thu May 19 16:50:00 2011 +0100 +++ b/win32.py Fri May 20 14:47:42 2011 +0100 @@ -47,7 +47,7 @@ else: ProcessTimes = namedtuple('ProcessTimes', 'kernel user') -__all__ = 'call', 'kill', 'terminate', 'wait', 'pause', 'clock' +__all__ = 'call', 'kill', 'pause', 'clock' from functools import wraps @@ -87,8 +87,8 @@ raise -# Automatically convert _subprocess handle objects into low-level HANDLEs -# and replicate their functionality for our own use +# Automatically convert _subprocess handle objects into low-level +# HANDLEs and replicate their functionality for our own use try: _subprocess_handle = type(GetCurrentProcess()) except NameError: @@ -541,9 +541,14 @@ def kill(process): - try: - process.terminate() - except AttributeError: - TerminateProcess(process._handle, 1) -terminate = kill -wait = subprocess.Popen.wait \ No newline at end of file + # Give up after three attempts + for i in range(3): + try: + try: + process.terminate() + except AttributeError: + TerminateProcess(process._handle, 1) + except WindowsError: + time.sleep(0) + else: + break