Victor Feng
Victor Feng

Reputation: 47

multiprocessing process grpc communicate async callback StatusCode.UNAVAILABLE

grpc request in process

from multiprocessing import Process, Manager

def frames_process(self):
    # fork process 
    self.frames_flag.value = True
    self.f_process = Process(target=self.frames_handle)
    self.f_process.start()

In frames_handle will request server through grpc client and the the result will be callback through default_cb by async

def default_cb(call_future):
    try:
        resp = call_future.result()
        logging.info("default_cb called {}".format(resp))
        return resp
    except Exception as e:
        logging.error("future_callback error: {}".format(e))

I use Python2 and grpc

The error is StatusCode.UNAVAILABLE

Thanks in advance.

Upvotes: 0

Views: 911

Answers (1)

Eric G
Eric G

Reputation: 4058

It's not clear to me from the code snippets how exactly your client code is intended to work or when it is invoking fork (via the multiprocessing libary), but gRPC Python clients are not, by default, compatible with the fork syscall. If you are forking at any time after creating a gRPC Python channel, this may explain the errors you are encountering. You can try running with the environment variable GRPC_ENABLE_FORK_SUPPORT=1, which was added in gRPC Python v1.15.0 to turn on client-side fork support.

Upvotes: 1

Related Questions