windows check_pid
This commit is contained in:
parent
1c99e3277b
commit
5bf87bc64d
1 changed files with 16 additions and 5 deletions
21
oml/utils.py
21
oml/utils.py
|
@ -369,12 +369,23 @@ def update_static():
|
||||||
)
|
)
|
||||||
|
|
||||||
def check_pid(pid):
|
def check_pid(pid):
|
||||||
try:
|
if sys.platform == 'win32':
|
||||||
os.kill(pid, 0)
|
import ctypes
|
||||||
except:
|
kernel32 = ctypes.windll.kernel32
|
||||||
return False
|
SYNCHRONIZE = 0x100000
|
||||||
|
process = kernel32.OpenProcess(SYNCHRONIZE, 0, pid)
|
||||||
|
if process != 0:
|
||||||
|
kernel32.CloseHandle(process)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
try:
|
||||||
|
os.kill(pid, 0)
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def check_pidfile(pid):
|
def check_pidfile(pid):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue