Skip to content

Commit 8e92478

Browse files
elpransmaiqbal11
authored andcommitted
Fix handling of multiple Out params (#317)
Fixes: #296
1 parent 4b1cb3c commit 8e92478

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

azure/functions_worker/dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ async def _handle__invocation_request(self, req):
295295
output_data = []
296296
if fi.output_types:
297297
for out_name, out_type_info in fi.output_types.items():
298-
val = args[name].get()
298+
val = args[out_name].get()
299299
if val is None:
300300
# TODO: is the "Out" parameter optional?
301301
# Can "None" be marshaled into protos.TypedData?
@@ -308,7 +308,7 @@ async def _handle__invocation_request(self, req):
308308

309309
output_data.append(
310310
protos.ParameterBinding(
311-
name=name,
311+
name=out_name,
312312
data=rpc_val))
313313

314314
return_value = None
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"scriptFile": "main.py",
3+
"disabled": false,
4+
5+
"bindings": [
6+
{
7+
"type": "httpTrigger",
8+
"direction": "in",
9+
"name": "req"
10+
},
11+
{
12+
"name": "resp",
13+
"type": "http",
14+
"direction": "out"
15+
},
16+
{
17+
"direction": "out",
18+
"name": "msg",
19+
"queueName": "testqueue-return-multiple-outparam",
20+
"connection": "AzureWebJobsStorage",
21+
"type": "queue"
22+
}
23+
]
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import azure.functions as func
2+
3+
4+
def main(req: func.HttpRequest, resp: func.Out[func.HttpResponse],
5+
msg: func.Out[func.QueueMessage]) -> None:
6+
data = req.get_body().decode()
7+
msg.set(func.QueueMessage(body=data))
8+
resp.set(func.HttpResponse(body='HTTP response: {}'.format(data)))

tests/test_queue_functions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ def test_queue_return_multiple(self):
6161

6262
# wait for queue_trigger to process the queue item
6363
time.sleep(1)
64+
65+
def test_queue_return_multiple_outparam(self):
66+
r = self.webhost.request('POST', 'put_queue_multiple_out',
67+
data='foo')
68+
self.assertTrue(200 <= r.status_code < 300)
69+
self.assertEqual(r.text, 'HTTP response: foo')

0 commit comments

Comments
 (0)