【问题标题】:How to get Firestore collections and documents in Flask如何在 Flask 中获取 Firestore 集合和文档
【发布时间】:2021-08-23 08:29:29
【问题描述】:

我正在尝试从我的 Flask 服务器访问我的 Firestore 文档和集合。但是任何 get() 或 stream() 调用都会挂起,例如:

firestore_db.collection('users').get()

我知道我的服务凭证是有效的。我的 Firestore 调用在烧瓶应用程序之外执行良好。此外,当我创建一个新的、非常简单的 Flask 应用程序(就像这里的这个:https://stackoverflow.com/a/52680204/6424258)时,Firestore 调用工作。

关于我的完整 Flask 应用程序(也使用 sqlAlchemy 和 PostGres)的某些问题似乎扰乱了我与 Firebase 的连接。

调用 Firestore 后,我在日志文件中看到了这一点:

Checking ***credfile***.json for explicit credentials as part of auth process...
Making request: POST https://oauth2.googleapis.com/token
Starting new HTTPS connection (1): oauth2.googleapis.com:443

我使用的是 Python 3.6。

【问题讨论】:

    标签: python flask google-cloud-firestore


    【解决方案1】:

    好的,经过多次调试,我想我已经找到了一些东西。当我在我的烧瓶应用程序的 init.py 文件中注释掉这两行时,对 Firestore 的调用开始工作:

    import eventlet
    eventlet.monkey_patch()
    

    我相信我正在将这些行用于 websocket 聊天应用程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-09
      • 2018-04-09
      • 2018-03-29
      • 2019-09-24
      • 2019-11-13
      • 1970-01-01
      • 2018-04-04
      • 1970-01-01
      相关资源
      最近更新 更多