Azure / Azure/azure-functions-python-worker
Addressing Limitations in Python Function Execution Model with Asyncio Event Loop in Azure Functions
- 主要言語
- Python
- スター
- 357
- フォーク
- 116
- 平均マージ
- 32分
- マージ済み PR(30日)
- 1
説明
Description:
We have identified foundational limitations in the Python function execution model within the Azure Functions Python Worker that have impacted multiple durable Python customers. The current model runs all asynchronous function calls within a single asyncio event loop, leading to several constraints and challenges that need to be addressed:
Execution Order of Invocations:
The order in which invocations are received and executed is subject to the scheduling logic of the asyncio event loop, resulting in potentially random execution order. Currently, we cannot guarantee a first-come, first-served execution model.
Invocation Timeout Tracking:
There is no mechanism for tracking the real status of an invocation when it times out. The timeout could result from a genuinely long-running invocation, or it might be due to the worker not picking up the invocation for an extended period (e.g., 15 minutes) because the event loop is busy with other tasks. Additionally, the loop may become stuck processing one or more "bad" async calls (i.e., calls declared as async but performing blocking operations). The Function Host sends the request to the worker and begins measuring the timeout, but there is no explicit acknowledgment, status check, or fast-fail mechanism for these bad async calls currently in place.
Monitoring Event Loop Status:
Currently, there is no platform support for real-time monitoring of the asyncio event loop's running status or the ability to take snapshots to diagnose potential issues.
Reference to the relevant code: https://github.com/Azure/azure-functions-python-worker/blob/b734c57b3b81b3cad2f84951ee79c3a493504e32/azure_functions_worker/dispatcher.py#L659C13-L669C62
These challenges present significant difficulties for customers relying on durable/ non durable Python functions, and we are looking for potential enhancements to address these limitations.
++ @davidmrdavid @andystaples @vrdmr @gavin-aguiar @hallvictoria @fabiocav
### Expected Behavior
_No response_
### Relevant sample code snipped
_No response_
### Additional Information
_No response_
コントリビューションガイド
調査の方向性
azure_functions_worker/dispatcher.py の 659-669 行付近から始め、非同期の呼び出しがどのようにスケジュールされ、処理されるかを追跡します。コードを変更する前に、呼び出し順序、timeout の状態追跡、ブロッキングする非同期呼び出しの高速な失敗、およびイベントループの監視について、期待される動作を明確にします。合意した改善が検証可能な動作を伴って実装されれば完了ですが、現時点ではこの issue に具体的な受け入れ条件やテストはありません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- azure, python
- 領域
- backend, cloud
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100