Mahoni
Mahoni

Reputation: 7466

Using gRPC with gevent

I am using gRPC in a gevent monkey patched environment and I am seeing deadline exceeded for a deadline of 500ms. But the service responds in < 40ms. I am assuming this is due to the use of gevent, messing up the timing. But now where I have applied:

import grpc.experimental.gevent as grpc_gevent
grpc_gevent.init_gevent()

I am seeing DEADLINE_EXCEEDED even in my integration test.

Upvotes: 6

Views: 2491

Answers (2)

Nayan Shah
Nayan Shah

Reputation: 21

from gevent import monkey
monkey.patch_all()

import grpc._cython.cygrpc
grpc._cython.cygrpc.init_grpc_gevent()

ref : https://github.com/grpc/grpc/pull/14561#issue-301487490

Upvotes: 2

hupo
hupo

Reputation: 51

I'm having the same problem. After looking at init_gevent, I found a sentence:

This must be called AFTER the python standard lib has been patched, but BEFORE creating and gRPC objects.

Try adding the import at the top:

from gevent import monkey
monkey.patch_all()

Upvotes: 4

Related Questions