gpt4 book ai didi

python : Process calling GRPC server gets stuck and terminates unexpectedly

转载 作者:行者123 更新时间:2023-12-05 07:23:53 28 4
gpt4 key购买 nike

我有一个 GRPC 服务器正在运行。说:本地主机,46001

我有一个 python 程序,它正在创建一个包含 4 个进程的进程池。这里的进程池是自定义的:

Process_Pool(Process): have a process dict with 4 running process context.

我为我的用例维护了这个进程池。 注意:我在没有 GRPC 参与的情况下进行测试时,此功能运行良好。

GRPC 客户端实现如下:

class Client(object):

def __init__(self, host, port):
self.host = host
self.server_port = port
self.channel = grpc.insecure_channel("{}:{}".format(self.host, self.server_port))
self.stub = some_server_pb2_grpc.SomeInterfaceStub(self.channel)

当我从命令行运行它时,它工作正常:

python


client = Client("localhost", 46001)
my_dict= {'timestamp': 1555421947, 'additional_info': {}}
client.set_status(my_dict)

我面临的问题是,在从这 4 个进程创建对服务器的 GRPC 客户端调用时,例如:

client = Client("localhost", 46001)
client.set_status(some_dict)

进程意外终止。没有日志被进一步打印。我已经处理了所有异常,甚至是上述代码调用。

到目前为止,我唯一的推断是:GRPC 不适用于新生成的进程。

谁能帮我解决这个问题?

最佳答案

gRPC Python 客户端通过环境变量 GRPC_ENABLE_FORK_SUPPORT=1 支持多处理。

然而,gRPC Python 服务器的 fork 支持故事更为复杂(请参阅 https://github.com/grpc/grpc/issues/18321)。

关于 python : Process calling GRPC server gets stuck and terminates unexpectedly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55710628/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com