Handle another corner case on Windows

pull/23783/head
Lidi Zheng 5 years ago
parent 03813bf6fc
commit a5dc598a42
  1. 14
      src/python/grpcio/grpc/_cython/_cygrpc/aio/completion_queue.pyx.pxi

@ -21,18 +21,22 @@ cdef float _POLL_AWAKE_INTERVAL_S = 0.2
# loop.add_reader method.
cdef bint _has_fd_monitoring = True
IF UNAME_SYSNAME == "Windows":
cdef void _unified_socket_write(int fd) nogil:
win_socket_send(<WIN_SOCKET>fd, b"1", 1, 0)
# If the event loop policy is Proactor, then immediately turn on fall back
# mode.
if asyncio.get_event_loop_policy() == asyncio.WindowsProactorEventLoopPolicy:
_has_fd_monitoring = False
elif asyncio.get_event_loop_policy() == asyncio.DefaultEventLoopPolicy:
if sys.version_info >= (3, 8, 0):
try:
if hasattr(asyncio, 'WindowsProactorEventLoopPolicy') and \
isinstance(asyncio.get_event_loop_policy(), asyncio.WindowsProactorEventLoopPolicy):
_has_fd_monitoring = False
elif isinstance(asyncio.get_event_loop_policy(), asyncio.DefaultEventLoopPolicy):
if sys.version_info >= (3, 8, 0):
_has_fd_monitoring = False
except NameError:
# Pass if asyncio is not imported for 2.7
pass
ELSE:
from posix cimport unistd

Loading…
Cancel
Save