Hi @Vaibhav Jain
Thanks for reaching Microsoft Q&A team.
We have a limited support scope with Python and here are my recommendations at my best efforts.
Please try this code using asyncio:
async def save(directory_client, new_file_with_changes, tasks: list):
try:
async with directory_client:
tasks.append(asyncio.create_task(directory_client.upload_file(file_name=new_file_with_changes.name,
data=new_file_with_changes,
length=new_file_with_changes.size)))
await asyncio.gather(*tasks)
return Response.send_response(code=55)
except Exception as e:
# Handle exceptions here, log them, and possibly return an error response
return Response.send_response(code=500, message=f"Error uploading file: {str(e)}")
With these changes, your code should work more effectively for uploading files to Azure File Share using asyncio. Make sure to handle exceptions appropriately for robust error handling.
Please let us know if you have any further queries. I’m happy to assist you further.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.
Thanks!