diff options
author | kpayson64 <kpayson@google.com> | 2018-05-31 17:11:23 -0700 |
---|---|---|
committer | kpayson64 <kpayson@google.com> | 2018-05-31 17:35:48 -0700 |
commit | 0647b03296069af48cc79f0aca3719610ff178b0 (patch) | |
tree | 017e198b875a91d93adb9730e645249998f067c8 /src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | |
parent | f2979e32185804ee707ab18da844d74496aeb479 (diff) |
Use gevent greenlets for metadata callbacks
Diffstat (limited to 'src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi index 500086f6cb..dff9097bf9 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi @@ -17,6 +17,17 @@ cimport cpython import grpc import threading +def _spawn_callback_in_thread(cb_func, args): + threading.Thread(target=cb_func, args=args).start() + +async_callback_func = _spawn_callback_in_thread + +def set_async_callback_func(callback_func): + global async_callback_func + async_callback_func = callback_func + +def _spawn_callback_async(callback, args): + async_callback_func(callback, args) cdef class CallCredentials: @@ -40,7 +51,7 @@ cdef int _get_metadata( else: cb(user_data, NULL, 0, status, error_details) args = context.service_url, context.method_name, callback, - threading.Thread(target=<object>state, args=args).start() + _spawn_callback_async(<object>state, args) return 0 # Asynchronous return |