Addressing Limitations in Python Function Execution Model with Asyncio Event Loop in Azure Functions
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with azure_functions_worker/dispatcher.py around lines 659-669 and trace how asynchronous invocations are scheduled and handled. Clarify the expected behavior for invocation ordering, timeout status tracking, fast failure for blocking async calls, and event-loop monitoring before changing code. Done means the agreed enhancements are implemented with verifiable behavior, but the issue currently provides no specific acceptance criteria or tests.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 357
- Forks
- 116
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-functions-python-worker
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug python
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Azure/azure-functions-python-worker#1881 · 2 comments · 3 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
Azure/azure-functions-python-worker#1908 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Azure/azure-functions-python-worker#1906 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in Azure/azure-functions-python-worker
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100