Skip to content

Commit e802d63

Browse files
committed
moving flag set out of get_binding
1 parent 10a9039 commit e802d63

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

azure_functions_worker/bindings/meta.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,6 @@ def get_deferred_binding(bind_name: str,
224224

225225
# Checks if pytype is a supported sdk type
226226
if DEFERRED_BINDINGS_REGISTRY.check_supported_type(pytype):
227-
# Set flag once
228-
global DEFERRED_BINDINGS_ENABLED
229-
if not DEFERRED_BINDINGS_ENABLED:
230-
DEFERRED_BINDINGS_ENABLED = True
231227
# Returns deferred binding converter
232228
binding = DEFERRED_BINDINGS_REGISTRY.get(bind_name)
233229

@@ -237,6 +233,7 @@ def get_deferred_binding(bind_name: str,
237233
# This will catch if DEFERRED_BINDINGS_REGISTRY is None
238234
# It will be None if the library isn't imported
239235
# Ensure that the flag is set to False in this case
236+
global DEFERRED_BINDINGS_ENABLED
240237
DEFERRED_BINDINGS_ENABLED = False
241238

242239

azure_functions_worker/functions.py

+14
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ def validate_function_params(params: dict, bound_params: dict,
144144
param_has_anno = param.name in annotations
145145
param_anno = annotations.get(param.name)
146146

147+
# Check the declared type
148+
set_deferred_bindings_flag(param_anno)
149+
147150
if param_has_anno:
148151
if typing_inspect.is_generic_type(param_anno):
149152
param_anno_origin = typing_inspect.get_origin(param_anno)
@@ -423,3 +426,14 @@ def add_indexed_function(self, function):
423426
input_types,
424427
output_types,
425428
return_type)
429+
430+
431+
def set_deferred_bindings_flag(param_anno: type):
432+
# If flag hasn't already been set
433+
# If DEFERRED_BINDINGS_REGISTRY is not None
434+
# If the binding type is a deferred binding type
435+
if (not bindings_utils.meta.DEFERRED_BINDINGS_ENABLED
436+
and bindings_utils.meta.DEFERRED_BINDINGS_REGISTRY is not None
437+
and bindings_utils.meta.DEFERRED_BINDINGS_REGISTRY.check_supported_type(
438+
param_anno)):
439+
bindings_utils.meta.DEFERRED_BINDINGS_ENABLED = True

0 commit comments

Comments
 (0)