firebase / firebase/firebase-functions-python

Async support

未关闭
#135 17 条评论 10 个 reaction 已指派 0 人 在 GitHub 查看
feature-request
主要语言
Python
星标
167
派生
34
PR 合并指标
30 天内没有已合并 PR

描述

Would it make sense to support async functions here, so that the event handlers could be called in an async manner and consequently call async libraries?

This way a single instance could be handling more requests in parallel, for example if the cloud function calls several external APIs in a sequence to complete a process, and spends most of the time just waiting for responses, and uses only a little memory and CPU in general.

It is possible to call async code from the current sync functions, but it does not help with scalability, as the cloud function itself still blocks during the whole operation. This can help to do things in parallel in a cloud function, but not with sequential operations, which are common at least in our use case.

The original JS runtime is async, like all things Node, but also Python has standard async in version 3. Consequently, firebase-admin-python has worked on adding async support, since google-auth added async support in 2021. https://github.com/firebase/firebase-admin-python/issues/104

> Hey Folks, We just released [v5.3.0](https://github.com/firebase/firebase-admin-python/releases/tag/v5.3.0) which added async support for the Cloud Firestore API. This is the first step into fulfilling this FR so please give it a try and let us know what you think!

Starlette is a popular, lightweight ASGI framework which could maybe used for this, the same way Flask is for the sync version? https://www.starlette.io/

贡献指南

打开贡献指南

调研方向

未指定源文件、测试或入口点。首先映射当前同步事件处理器的入口点,并审查所引用的 Starlette 和 firebase-admin-python 异步工作。完成要求包括:定义异步处理器模型、完成其运行时集成,并记录对所述顺序和并发使用场景的覆盖情况。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend, cloud
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。