mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 05:57:18 +08:00
Patch redis-py bug for Windows (#8386)
This commit is contained in:
@@ -30,6 +30,10 @@ thirdparty_files = os.path.join(
|
||||
os.path.abspath(os.path.dirname(__file__)), "thirdparty_files")
|
||||
sys.path.insert(0, thirdparty_files)
|
||||
|
||||
if sys.platform == "win32":
|
||||
import ray.compat # noqa: E402
|
||||
ray.compat.patch_redis_empty_recv()
|
||||
|
||||
# Expose ray ABI symbols which may be dependent by other shared
|
||||
# libraries such as _streaming.so. See BUILD.bazel:_raylet
|
||||
python_shared_lib_suffix = ".so" if sys.platform != "win32" else ".pyd"
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import errno
|
||||
import socket
|
||||
import sys
|
||||
|
||||
|
||||
def patch_redis_empty_recv():
|
||||
"""On Windows, socket disconnect result in errors rather than empty reads.
|
||||
redis-py does not handle these errors correctly.
|
||||
This patch translates connection resets to empty reads as in POSIX.
|
||||
"""
|
||||
assert sys.platform == "win32"
|
||||
import redis
|
||||
|
||||
def redis_recv(sock, *args, **kwargs):
|
||||
result = b""
|
||||
try:
|
||||
result = redis._compat.recv(sock, *args, **kwargs)
|
||||
except socket.error as ex:
|
||||
if ex.errno not in [errno.ECONNRESET, errno.ECONNREFUSED]:
|
||||
raise
|
||||
return result
|
||||
|
||||
redis.connection.recv = redis_recv
|
||||
Reference in New Issue
Block a user