Skip to content

feat: set event loop to uvloop #1697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions azure_functions_worker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Main entrypoint."""

import argparse
import sys


def parse_args():
Expand Down Expand Up @@ -46,6 +47,12 @@ def main():
DependencyManager.use_worker_dependencies()

import asyncio
if sys.platform != 'win32':
try:
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ImportError:
pass

from . import logging
from .logging import error_logger, format_exception, logger
Expand All @@ -56,6 +63,7 @@ def main():
logger.info('Starting Azure Functions Python Worker.')
logger.info('Worker ID: %s, Request ID: %s, Host Address: %s:%s',
args.worker_id, args.request_id, args.host, args.port)
logger.debug('Using event loop: %s', type(asyncio.get_event_loop()))

try:
return asyncio.run(start_async(
Expand Down
1 change: 1 addition & 0 deletions eng/pack/templates/macos_64_env_gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ steps:
!werkzeug/debug/shared/debugger.js
!azure_functions_worker/**
!dateutil/**
!uvloop/**
targetFolder: '$(Build.ArtifactStagingDirectory)'
condition: eq(variables['proxyWorker'], true)
displayName: 'Copy proxy_worker files'
1 change: 1 addition & 0 deletions eng/pack/templates/nix_arm64_env_gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ steps:
!*.dist-info/**
!werkzeug/debug/shared/debugger.js
!dateutil/**
!uvloop/**
!azure_functions_worker/**
targetFolder: '$(Build.ArtifactStagingDirectory)'
condition: eq(variables['proxyWorker'], true)
Expand Down
1 change: 1 addition & 0 deletions eng/pack/templates/nix_env_gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ steps:
!*.dist-info/**
!werkzeug/debug/shared/debugger.js
!dateutil/**
!uvloop/**
!azure_functions_worker/**
targetFolder: '$(Build.ArtifactStagingDirectory)'
condition: eq(variables['proxyWorker'], true)
Expand Down
4 changes: 4 additions & 0 deletions eng/templates/jobs/ci-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
PYTHON_VERSION: '3.12'
Python313:
PYTHON_VERSION: '3.13'
pool:
name: ${{ parameters.PoolName }}
image: 1es-ubuntu-22.04
os: linux
steps:
- task: UsePythonVersion@0
inputs:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ classifiers = [
dependencies = [
"azure-functions==1.24.0b3",
"python-dateutil~=2.9.0",
"uvloop~=0.21.0; python_version >= '3.8'",
"protobuf~=3.19.3; python_version == '3.7'",
"protobuf~=4.25.3; python_version >= '3.8' and python_version < '3.13'",
"protobuf~=5.29.0; python_version >= '3.13'",
Expand Down
Loading