Merge pull request #18456 from jhance/gil-fix

Make gil handling in completion queue more robust
pull/18519/head
Lidi Zheng 6 years ago committed by GitHub
commit 5268858e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi

@ -30,19 +30,20 @@ cdef grpc_event _next(grpc_completion_queue *c_completion_queue, deadline):
else:
c_deadline = _timespec_from_time(deadline)
with nogil:
while True:
while True:
with nogil:
c_timeout = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), c_increment)
if gpr_time_cmp(c_timeout, c_deadline) > 0:
c_timeout = c_deadline
c_event = grpc_completion_queue_next(c_completion_queue, c_timeout, NULL)
if (c_event.type != GRPC_QUEUE_TIMEOUT or
gpr_time_cmp(c_timeout, c_deadline) == 0):
break
# Handle any signals
with gil:
cpython.PyErr_CheckSignals()
# Handle any signals
cpython.PyErr_CheckSignals()
return c_event

Loading…
Cancel
Save