Azure / Azure/azure-functions-python-worker

Addressing Limitations in Python Function Execution Model with Asyncio Event Loop in Azure Functions

Offen
#1,574 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:python-functions feature python
Vorherrschende Sprache
Python
Sterne
357
Forks
116
Ø Merge
32 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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_

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in azure_functions_worker/dispatcher.py etwa bei den Zeilen 659-669 und verfolge, wie asynchrone Aufrufe geplant und behandelt werden. Kläre das erwartete Verhalten für die Reihenfolge der Aufrufe, die Verfolgung des timeout-Status, das schnelle Fehlschlagen bei blockierenden asynchronen Aufrufen und die Überwachung der Ereignisschleife, bevor du den Code änderst. Als erledigt gilt die Aufgabe, wenn die vereinbarten Verbesserungen mit überprüfbarem Verhalten implementiert sind; das Issue enthält derzeit jedoch keine spezifischen Abnahmekriterien oder Tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
backend, cloud
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.