mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 02:22:13 +08:00
Make more tests run on Windows (#8446)
* Remove worker Wait() call due to SIGCHLD being ignored * Port _pid_alive to Windows * Show PID as well as TID in glog * Update TensorFlow version for Python 3.8 on Windows * Handle missing Pillow on Windows * Work around dm-tree PermissionError on Windows * Fix some lint errors on Windows with Python 3.8 * Simplify torch requirements * Quiet git clean * Handle finalizer issues * Exit with the signal number * Get rid of wget * Fix some Windows compatibility issues with tests Co-authored-by: Mehrdad <noreply@github.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import errno
|
||||
import json
|
||||
import fnmatch
|
||||
import os
|
||||
@@ -12,6 +13,9 @@ import ray
|
||||
|
||||
import psutil # We must import psutil after ray because we bundle it with ray.
|
||||
|
||||
if sys.platform == "win32":
|
||||
import _winapi
|
||||
|
||||
|
||||
class RayTestTimeoutException(Exception):
|
||||
"""Exception used to identify timeouts from test utilities."""
|
||||
@@ -27,11 +31,24 @@ def _pid_alive(pid):
|
||||
Returns:
|
||||
This returns false if the process is dead. Otherwise, it returns true.
|
||||
"""
|
||||
no_such_process = errno.EINVAL if sys.platform == "win32" else errno.ESRCH
|
||||
alive = True
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
return True
|
||||
except OSError:
|
||||
return False
|
||||
if sys.platform == "win32":
|
||||
SYNCHRONIZE = 0x00100000 # access mask defined in <winnt.h>
|
||||
handle = _winapi.OpenProcess(SYNCHRONIZE, False, pid)
|
||||
try:
|
||||
alive = (_winapi.WaitForSingleObject(handle, 0) !=
|
||||
_winapi.WAIT_OBJECT_0)
|
||||
finally:
|
||||
_winapi.CloseHandle(handle)
|
||||
else:
|
||||
os.kill(pid, 0)
|
||||
except OSError as ex:
|
||||
if ex.errno != no_such_process:
|
||||
raise
|
||||
alive = False
|
||||
return alive
|
||||
|
||||
|
||||
def wait_for_pid_to_exit(pid, timeout=20):
|
||||
|
||||
Reference in New Issue
Block a user