Show More
@@ -36,6 +36,7 b' from IPython.core.application import (' | |||
|
36 | 36 | base_flags as base_ip_flags |
|
37 | 37 | ) |
|
38 | 38 | from IPython.utils.path import expand_path |
|
39 | from IPython.utils.process import check_pid | |
|
39 | 40 | from IPython.utils import py3compat |
|
40 | 41 | from IPython.utils.py3compat import unicode_type |
|
41 | 42 | |
@@ -249,28 +250,11 b' class BaseParallelApplication(BaseIPythonApplication):' | |||
|
249 | 250 | raise PIDFileError('pid file not found: %s' % pid_file) |
|
250 | 251 | |
|
251 | 252 | def check_pid(self, pid): |
|
252 | if os.name == 'nt': | |
|
253 | try: | |
|
254 | import ctypes | |
|
255 | # returns 0 if no such process (of ours) exists | |
|
256 | # positive int otherwise | |
|
257 | p = ctypes.windll.kernel32.OpenProcess(1,0,pid) | |
|
258 | except Exception: | |
|
259 | self.log.warn( | |
|
260 | "Could not determine whether pid %i is running via `OpenProcess`. " | |
|
261 | " Making the likely assumption that it is."%pid | |
|
262 | ) | |
|
263 | return True | |
|
264 | return bool(p) | |
|
265 | else: | |
|
266 | try: | |
|
267 | p = Popen(['ps','x'], stdout=PIPE, stderr=PIPE) | |
|
268 | output,_ = p.communicate() | |
|
269 | except OSError: | |
|
270 | self.log.warn( | |
|
271 | "Could not determine whether pid %i is running via `ps x`. " | |
|
272 | " Making the likely assumption that it is."%pid | |
|
273 | ) | |
|
274 | return True | |
|
275 | pids = list(map(int, re.findall(br'^\W*\d+', output, re.MULTILINE))) | |
|
276 | return pid in pids | |
|
253 | try: | |
|
254 | return check_pid(pid) | |
|
255 | except Exception: | |
|
256 | self.log.warn( | |
|
257 | "Could not determine whether pid %i is running. " | |
|
258 | " Making the likely assumption that it is."%pid | |
|
259 | ) | |
|
260 | return True |
General Comments 0
You need to be logged in to leave comments.
Login now