0
votes

i try to Launch a simple azure function in parallel but it doesnt work according to the fan in / fan out model.

def orchestrator_function(context: df.DurableOrchestrationContext):

try:

    parallel_tasks  = []
    parallel_tasks.append(context.call_activity("Hello2","paris"))
    parallel_tasks.append(context.call_activity("Hello2","tokyo"))
    outputs = yield context.task_all(parallel_tasks)
    return outputs

my activity hello2:

def main(name: str) -> str:
    logging.warning("job launched : "+ name)
    time.sleep(30)
    logging.warning("finished : "+ name)
return f"Hello {name}!"

view of the logging view of the logging

My problem is that when I run the durable function, the activities do not run in parallel but one after the other. I used the example of Azure: https://docs.microsoft.com/fr-fr/azure/azure-functions/durable/durable-functions-overview?tabs=python

I put a time.sleep in order to see if each activities are running in parallel.

Do you have an idea about how i can i resolve my issue? Thanks

1

1 Answers

0
votes

Your activity function must be an asnychronous function. Using asyncio.sleep instead of time.sleep.

import logging
import asyncio
async def main(name: str) -> str:
    logging.warning("job launched : "+ name)
    asyncio.sleep(3000)
    logging.warning("finished : "+ name)
    return f"Hello {name}!"