Skip to content

Commit 181d76b

Browse files
authored
Merge branch 'dev' into hallvictoria/linuxarm64
2 parents a617468 + ae4d1bc commit 181d76b

File tree

3 files changed

+1
-135
lines changed

3 files changed

+1
-135
lines changed

azure_functions_worker/bindings/meta.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
BINDING_REGISTRY = None
2424
DEFERRED_BINDING_REGISTRY = None
25-
deferred_bindings_cache = {}
2625

2726

2827
def _check_http_input_type_annotation(bind_name: str, pytype: type,
@@ -285,48 +284,8 @@ def deferred_bindings_decode(binding: typing.Any,
285284
datum: typing.Any,
286285
metadata: typing.Any,
287286
function_name: str):
288-
"""
289-
This cache holds deferred binding types (ie. BlobClient, ContainerClient)
290-
That have already been created, so that the worker can reuse the
291-
Previously created type without creating a new one.
292-
293-
For async types, the function_name is needed as a key to differentiate.
294-
This prevents a known SDK issue where reusing a client across functions
295-
can lose the session context and cause an error.
296-
297-
The cache key is based on: param name, type, resource, function_name
298287

299-
If cache is empty or key doesn't exist, deferred_binding_type is None
300-
"""
301-
global deferred_bindings_cache
302-
303-
# Only applies to Event Hub and Service Bus - cannot cache
304-
# These types will always produce different content and are not clients
305-
if (datum.type == "collection_model_binding_data"
306-
or datum.value.source == "AzureEventHubsEventData"
307-
or datum.value.source == "AzureServiceBusReceivedMessage"):
308-
return binding.decode(datum,
309-
trigger_metadata=metadata,
310-
pytype=pytype)
311-
312-
if deferred_bindings_cache.get((pb.name,
313-
pytype,
314-
datum.value.content,
315-
function_name), None) is not None:
316-
return deferred_bindings_cache.get((pb.name,
317-
pytype,
318-
datum.value.content,
319-
function_name))
320-
else:
321-
deferred_binding_type = binding.decode(datum,
322-
trigger_metadata=metadata,
323-
pytype=pytype)
324-
325-
deferred_bindings_cache[(pb.name,
326-
pytype,
327-
datum.value.content,
328-
function_name)] = deferred_binding_type
329-
return deferred_binding_type
288+
return binding.decode(datum, trigger_metadata=metadata, pytype=pytype)
330289

331290

332291
def check_deferred_bindings_enabled(param_anno: type,

tests/extension_tests/deferred_bindings_tests/deferred_bindings_blob_functions/function_app.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -249,41 +249,6 @@ def put_blob_bytes(req: func.HttpRequest, file: func.Out[bytes]) -> str:
249249
return 'OK'
250250

251251

252-
@app.function_name(name="blob_cache")
253-
@app.blob_input(arg_name="cachedClient",
254-
path="python-worker-tests/test-blobclient-triggered.txt",
255-
connection="AzureWebJobsStorage")
256-
@app.route(route="blob_cache")
257-
def blob_cache(req: func.HttpRequest,
258-
cachedClient: blob.BlobClient) -> str:
259-
return func.HttpResponse(repr(cachedClient))
260-
261-
262-
@app.function_name(name="blob_cache2")
263-
@app.blob_input(arg_name="cachedClient",
264-
path="python-worker-tests/test-blobclient-triggered.txt",
265-
connection="AzureWebJobsStorage")
266-
@app.route(route="blob_cache2")
267-
def blob_cache2(req: func.HttpRequest,
268-
cachedClient: blob.BlobClient) -> func.HttpResponse:
269-
return func.HttpResponse(repr(cachedClient))
270-
271-
272-
@app.function_name(name="blob_cache3")
273-
@app.blob_input(arg_name="cachedClient",
274-
path="python-worker-tests/test-blobclient-triggered.txt",
275-
connection="AzureWebJobsStorage")
276-
@app.blob_input(arg_name="cachedClient2",
277-
path="python-worker-tests/test-blobclient-triggered.txt",
278-
connection="AzureWebJobsStorage")
279-
@app.route(route="blob_cache3")
280-
def blob_cache3(req: func.HttpRequest,
281-
cachedClient: blob.BlobClient,
282-
cachedClient2: blob.BlobClient) -> func.HttpResponse:
283-
return func.HttpResponse("Client 1: " + repr(cachedClient)
284-
+ " | Client 2: " + repr(cachedClient2))
285-
286-
287252
@app.function_name(name="invalid_connection_info")
288253
@app.blob_input(arg_name="client",
289254
path="python-worker-tests/test-blobclient-triggered.txt",

tests/extension_tests/deferred_bindings_tests/test_deferred_bindings_blob_functions.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -171,64 +171,6 @@ def test_type_undefined(self):
171171
self.assertEqual(r.status_code, 200)
172172
self.assertEqual(r.text, 'test-data')
173173

174-
@unittest.skipIf(sys.version_info.minor >= 13, "For python 3.13+,"
175-
"the cache is maintained in the ext and TBD.")
176-
def test_caching(self):
177-
'''
178-
The cache returns the same type based on resource and function name.
179-
Two different functions with clients that access the same resource
180-
will have two different clients. This tests that the same client
181-
is returned for each invocation and that the clients are different
182-
between the two functions.
183-
'''
184-
185-
r = self.webhost.request('GET', 'blob_cache')
186-
r2 = self.webhost.request('GET', 'blob_cache2')
187-
self.assertEqual(r.status_code, 200)
188-
self.assertEqual(r2.status_code, 200)
189-
client = r.text
190-
client2 = r2.text
191-
self.assertNotEqual(client, client2)
192-
193-
r = self.webhost.request('GET', 'blob_cache')
194-
r2 = self.webhost.request('GET', 'blob_cache2')
195-
self.assertEqual(r.status_code, 200)
196-
self.assertEqual(r2.status_code, 200)
197-
self.assertEqual(r.text, client)
198-
self.assertEqual(r2.text, client2)
199-
self.assertNotEqual(r.text, r2.text)
200-
201-
r = self.webhost.request('GET', 'blob_cache')
202-
r2 = self.webhost.request('GET', 'blob_cache2')
203-
self.assertEqual(r.status_code, 200)
204-
self.assertEqual(r2.status_code, 200)
205-
self.assertEqual(r.text, client)
206-
self.assertEqual(r2.text, client2)
207-
self.assertNotEqual(r.text, r2.text)
208-
209-
@unittest.skipIf(sys.version_info.minor >= 13, "For python 3.13+,"
210-
"the cache is maintained in the ext and TBD.")
211-
def test_caching_same_resource(self):
212-
'''
213-
The cache returns the same type based on param name.
214-
One functions with two clients that access the same resource
215-
will have two different clients. This tests that the same clients
216-
are returned for each invocation and that the clients are different
217-
between the two bindings.
218-
'''
219-
220-
r = self.webhost.request('GET', 'blob_cache3')
221-
self.assertEqual(r.status_code, 200)
222-
clients = r.text.split(" | ")
223-
self.assertNotEqual(clients[0], clients[1])
224-
225-
r2 = self.webhost.request('GET', 'blob_cache3')
226-
self.assertEqual(r2.status_code, 200)
227-
clients_second_call = r2.text.split(" | ")
228-
self.assertEqual(clients[0], clients_second_call[0])
229-
self.assertEqual(clients[1], clients_second_call[1])
230-
self.assertNotEqual(clients_second_call[0], clients_second_call[1])
231-
232174
def test_failed_client_creation(self):
233175
r = self.webhost.request('GET', 'invalid_connection_info')
234176
# Without the http_v2_enabled default definition, this request would time out.

0 commit comments

Comments
 (0)