Skip to content

Commit 37d07da

Browse files
committed
Enabled dependency isolation by default
1 parent 0ed9017 commit 37d07da

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

azure_functions_worker/constants.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@
4343
PYTHON_THREADPOOL_THREAD_COUNT_MAX = sys.maxsize
4444
PYTHON_THREADPOOL_THREAD_COUNT_MAX_37 = 32
4545

46-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = False
47-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 = False
46+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT = True
4847
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT = False
4948
PYTHON_ENABLE_WORKER_EXTENSIONS_DEFAULT_39 = True
5049

azure_functions_worker/loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def index_function_app(function_path: str) -> List[Function]:
147147

148148
app: Optional[FunctionApp] = None
149149
for i in imported_module.__dir__():
150-
if isinstance(getattr(imported_module, i, None), FunctionApp):
150+
if type(getattr(imported_module, i,
151+
None)).__name__ == FunctionApp.__name__:
151152
if not app:
152153
app = getattr(imported_module, i, None)
153154
else:

azure_functions_worker/utils/dependency.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
from azure_functions_worker.utils.common import is_true_like
2-
from typing import List, Optional
3-
from types import ModuleType
41
import importlib
52
import inspect
63
import os
74
import re
85
import sys
6+
from types import ModuleType
7+
from typing import List, Optional
98

10-
from ..logging import logger
9+
from azure_functions_worker.utils.common import is_true_like
1110
from ..constants import (
1211
AZURE_WEBJOBS_SCRIPT_ROOT,
1312
CONTAINER_NAME,
1413
PYTHON_ISOLATE_WORKER_DEPENDENCIES,
15-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT,
16-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310
14+
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
1715
)
18-
from ..utils.common import is_python_version
16+
from ..logging import logger
1917
from ..utils.wrappers import enable_feature_by
2018

2119

@@ -75,12 +73,7 @@ def is_in_linux_consumption(cls):
7573
@classmethod
7674
@enable_feature_by(
7775
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
78-
flag_default=(
79-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
80-
is_python_version('3.10') else
81-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
82-
)
83-
)
76+
flag_default=PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT)
8477
def use_worker_dependencies(cls):
8578
"""Switch the sys.path and ensure the worker imports are loaded from
8679
Worker's dependenciess.
@@ -106,12 +99,7 @@ def use_worker_dependencies(cls):
10699
@classmethod
107100
@enable_feature_by(
108101
flag=PYTHON_ISOLATE_WORKER_DEPENDENCIES,
109-
flag_default=(
110-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
111-
is_python_version('3.10') else
112-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
113-
)
114-
)
102+
flag_default=PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT)
115103
def prioritize_customer_dependencies(cls, cx_working_dir=None):
116104
"""Switch the sys.path and ensure the customer's code import are loaded
117105
from CX's deppendencies.
@@ -180,11 +168,7 @@ def reload_customer_libraries(cls, cx_working_dir: str):
180168
"""
181169
use_new_env = os.getenv(PYTHON_ISOLATE_WORKER_DEPENDENCIES)
182170
if use_new_env is None:
183-
use_new = (
184-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT_310 if
185-
is_python_version('3.10') else
186-
PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
187-
)
171+
use_new = PYTHON_ISOLATE_WORKER_DEPENDENCIES_DEFAULT
188172
else:
189173
use_new = is_true_like(use_new_env)
190174

tests/endtoend/dependency_isolation_functions/dependency_isolation_stein/function_app.py

Whitespace-only changes.

0 commit comments

Comments
 (0)