diff options
Diffstat (limited to 'src/python/grpcio')
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 5 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 9 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_cython/cygrpc.pyx | 11 |
3 files changed, 18 insertions, 7 deletions
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 1295009809..9d6e017026 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -28,11 +28,14 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cimport libc.time -from libc.stdint cimport int64_t, uint32_t, int32_t cdef extern from "grpc/_cython/loader.h": + ctypedef int int32_t + ctypedef unsigned uint32_t + ctypedef long int64_t + int pygrpc_load_core(const char*) void *gpr_malloc(size_t size) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index d7ad9e5215..9e14b967e0 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -146,8 +146,13 @@ cdef class Timespec: gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME)) return <double>real_time.seconds + <double>real_time.nanoseconds / 1e9 - infinite_future = Timespec(float("+inf")) - infinite_past = Timespec(float("-inf")) + @staticmethod + def infinite_future(): + return Timespec(float("+inf")) + + @staticmethod + def infinite_past(): + return Timespec(float("-inf")) cdef class CallDetails: diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index fd1443e790..3967c3045f 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -47,16 +47,19 @@ include "grpc/_cython/_cygrpc/server.pyx.pxi" cdef class _ModuleState: + cdef bint is_loaded + def __cinit__(self): filename = pkg_resources.resource_filename( - __name__, '_windows/grpc_c.64.python') - directory = os.path.dirname(filename) - if not pygrpc_load_core(directory): + 'grpc._cython', '_windows/grpc_c.64.python') + if not pygrpc_load_core(filename): raise ImportError('failed to load core gRPC library') grpc_init() + self.is_loaded = True def __dealloc__(self): - grpc_shutdown() + if self.is_loaded: + grpc_shutdown() _module_state = _ModuleState() |