在 Nameko rpc 函数中阻止 Firestore https 调用

问题描述

使用 nameko rpc、firestore 的简单服务。

class GreetingService:
    name = "greeting_service"

    @rpc
    def hello(self,name):
        cred = credentials.Certificate("...")
        firebase_admin.initialize_app(cred)
        client = firestore.client()
        ref = client.db.collection("/users")
        ref.add({'name': name}) # BLOCKED
        return "Hello,{}!".format(name)

调用 rpc 方法时,最后的调试日志是:

Making request: POST https://oauth2.googleapis.com/token
Starting new HTTPS connection (1): oauth2.googleapis.com:443

之后什么也没有发生,请求没有完成,也没有抛出任何错误。我想这与并发和/或解释器以某种方式被 https 请求阻止有关...

我的研究笔记如下。

Firestore 代码自行运行,没有任何问题。在这种情况下,只能在 Firestore 创建的实例上没有问题。

Lib 版本(使用不同的 urllib3 1.25.,1.26. 并且存在 https/socket 连接问题的常见问题):

nameko                        2.12.0
firebase-admin                4.5.1
urllib3                       1.25.10

花了几个小时玩线程,甚至处理 asyncio lib 和其他类似的东西(来自 nameko 的 DependencyProvider、ThreadPoolExecutor、ProcesspoolExecutor、线程、多处理)。

尝试“黑客”,例如:https://hiranya911.medium.com/firebase-python-admin-sdk-with-asyncio-d65f39463916

目前没有进展 - 欢迎提出任何建议。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)