Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource leak in Microsoft Azure Form Recognizer azure.ai.formrecognizer.aio.DocumentAnalysisClient unclosed aiohttp Client Session #37403

Closed
abhijithautoai opened this issue Sep 14, 2024 · 6 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Document Intelligence issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@abhijithautoai
Copy link

  • azure-ai-formrecognizer
  • 3.3.3
  • Ubuntu 22
  • Python 3.9.2

While calling azure.ai.formrecognizer.aio.DocumentAnalysisClient for doing ocr for 200 pages using async event loop i am intermittently getting "Unclosed client session warnings". Some of the aiohttp sessions internally created in the client is not closed.

client initialisation code is : self.client = DocumentAnalysisClient(self.config_dict["FORM_RECOGNIZER_ENDPOINT"], credential=DefaultAzureCredential(),
api_version = self.config_dict["FORM_RECOGNIZER_API_VERSION"]
session=session,
,session_owner = False
)
I am passing an aiohttp Session to the client and i am closed the session using async with.
the client is also wrapped around async with.
I tried without passing the session created by me, the resource leak error still persists.

async with aiohttp.ClientSession() as session:
print_active_sessions()
async with await get_ocr_reader(session=session) as reader:
result = await analyze_files( model_id, page_image_list)
return result
this is the consumer code.

To Reproduce

  1. Using the client do ocr for 200 pages. Sleep for 3 min Again do ocr for 200 pages. Sleep for 3 min while doing it the third time one will get the resource leak warning.

Ideally all sessions created by DocumentAnalysisClient should be closed by it. If user is passing a session, then the client should use that session and should not create any sessions for itself.

aiohttp version is 3.10.5

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 14, 2024
@xiangyan99 xiangyan99 added Document Intelligence and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Sep 16, 2024
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 16, 2024
@xiangyan99
Copy link
Member

Thanks for the feedback, we’ll investigate asap.

@YalinLi0312
Copy link
Member

Hi @abhijithautoai , the unclosed session is from credential, you should manually close it or using with keyword. Please follow the examples in this doc: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/README.md#async-credentials

@YalinLi0312 YalinLi0312 added needs-author-feedback Workflow: More information is needed from author to address the issue. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. labels Sep 30, 2024
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Sep 30, 2024
Copy link

Hi @abhijithautoai. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

@github-actions github-actions bot removed the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Sep 30, 2024
Copy link

Hi @abhijithautoai. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

@github-actions github-actions bot removed the needs-author-feedback Workflow: More information is needed from author to address the issue. label Sep 30, 2024
@YalinLi0312 YalinLi0312 added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Sep 30, 2024
Copy link

Hi @abhijithautoai. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

Copy link

github-actions bot commented Oct 8, 2024

Hi @abhijithautoai, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.

@github-actions github-actions bot closed this as completed Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Document Intelligence issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants