Fix potential deadlock on the GIL (#26009)

pull/26024/head
Richard Belleville 4 years ago committed by GitHub
parent cca9277963
commit da2cf25592
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
  2. 2
      src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi

@ -45,12 +45,17 @@ cdef int _get_metadata(void *state,
cdef size_t metadata_count
cdef grpc_metadata *c_metadata
def callback(metadata, grpc_status_code status, bytes error_details):
cdef char* c_error_details = NULL
if error_details is not None:
c_error_details = <char*> error_details
if status == StatusCode.ok:
_store_c_metadata(metadata, &c_metadata, &metadata_count)
cb(user_data, c_metadata, metadata_count, status, NULL)
with nogil:
cb(user_data, c_metadata, metadata_count, status, NULL)
_release_c_metadata(c_metadata, metadata_count)
else:
cb(user_data, NULL, 0, status, error_details)
with nogil:
cb(user_data, NULL, 0, status, c_error_details)
args = context.service_url, context.method_name, callback,
_spawn_callback_async(<object>state, args)
return 0 # Asynchronous return

@ -583,7 +583,7 @@ cdef extern from "grpc/grpc_security.h":
ctypedef void (*grpc_credentials_plugin_metadata_cb)(
void *user_data, const grpc_metadata *creds_md, size_t num_creds_md,
grpc_status_code status, const char *error_details)
grpc_status_code status, const char *error_details) nogil
ctypedef struct grpc_metadata_credentials_plugin:
int (*get_metadata)(

Loading…
Cancel
Save