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 摘要。