Skip to content

feat: allow event loop to be 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 13 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
9 changes: 7 additions & 2 deletions workers/azure_functions_worker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"""Main entrypoint."""

import argparse
import asyncio
try:
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except Exception:
pass


def parse_args():
Expand Down Expand Up @@ -45,8 +51,6 @@ def main():
DependencyManager.initialize()
DependencyManager.use_worker_dependencies()

import asyncio

from . import logging
from .logging import error_logger, format_exception, logger

Expand All @@ -56,6 +60,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
2 changes: 1 addition & 1 deletion workers/azure_functions_worker/utils/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def should_load_cx_dependencies(cls):
)
def use_worker_dependencies(cls):
"""Switch the sys.path and ensure the worker imports are loaded from
Worker's dependenciess.
Worker's dependencies.

This will not affect already imported namespaces, but will clear out
the module cache and ensure the upcoming modules are loaded from
Expand Down
Loading