StreamChatAsync does not clean up resources according to httpaio
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par inspecter stream_chat/async_chat/client.py, en particulier la création de ClientSession et le chemin de nettoyage aexit. Reproduisez le scénario AWS Lambda ou AsyncBatchProcessor décrit dans l'issue et suivez les avertissements concernant les sessions et connecteurs non fermés. C'est terminé lorsque l'utilisation signalée n'émet plus ces avertissements de ressources.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary:
httpaio generates error messages due to an unclosed connection.
Having taken a quick look at stream_chat/async_chat/client.py, calling session.close() on aexit does not satisfy httpaio in my scenario.
Environment:
AWS Lambda
AWS Powertools v2.34.2 via AsyncBatchProcessor
stream-chat v4.12.1
Python v3.11
Relevant error messages:
"2024-03-25T22:26:43.353Z","[ERROR] 2024-03-25T22:26:43.353Z 2f7ab88d-c683-46f7-b6dc-616ab9f3241f Unclosed client session"
"2024-03-25T22:26:43.353Z","connector: <aiohttp.connector.TCPConnector object at 0x7fdf32456f50>"
"2024-03-25T22:26:43.353Z","connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fdf1a99a970>, 331.795931377)]']"
"2024-03-25T22:26:43.353Z","[ERROR] 2024-03-25T22:26:43.353Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Unclosed connector"
Verbose log:
Date,Message
"2024-03-25T22:26:43.407Z","REPORT RequestId: 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Duration: 499.26 ms Billed Duration: 500 ms Memory Size: 1024 MB Max Memory Used: 395 MB"
"2024-03-25T22:26:43.407Z","END RequestId: 2f7ab88c-b683-46f7-b6dc-616ab9f3241f"
"2024-03-25T22:26:43.404Z","[WARNING] 2024-03-25T22:26:43.404Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Executing <Task finished name='Task-6' coro=<AsyncBatchProcessor._async_process_record() done, defined at /var/task/aws_lambda_powertools/utilities/batch/base.py:634> result=('success', ...) created at /var/lang/lib/python3.11/asyncio/tasks.py:680> took 0.475 seconds"
"2024-03-25T22:26:43.353Z","super().__init__("
"2024-03-25T22:26:43.353Z","File ""/var/task/aiohttp/connector.py"", line 776, in __init__"
"2024-03-25T22:26:43.353Z","connector=aiohttp.TCPConnector(keepalive_timeout=59.0),"
"2024-03-25T22:26:43.353Z","File ""/var/task/stream_chat/async_chat/client.py"", line 68, in __init__"
"2024-03-25T22:26:43.353Z","client = StreamChatAsync("
"2024-03-25T22:26:43.353Z","File ""/var/task/helpers/streamchat_client.py"", line 18, in __init__"
"2024-03-25T22:26:43.353Z","stream_client = StreamChatClient(completionRequested.conversation.channelId)"
"2024-03-25T22:26:43.353Z","File ""/var/task/categorizer.py"", line 56, in async_record_handler"
"2024-03-25T22:26:43.353Z","result = await self.handler(record=data)"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/base.py"", line 649, in _async_process_record"
"2024-03-25T22:26:43.353Z","self._context.run(self._callback, *self._args)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/events.py"", line 84, in _run"
"2024-03-25T22:26:43.353Z","handle._run()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 1928, in _run_once"
"2024-03-25T22:26:43.353Z","self._run_once()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 608, in run_forever"
"2024-03-25T22:26:43.353Z","self.run_forever()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 641, in run_until_complete"
"2024-03-25T22:26:43.353Z","return loop.run_until_complete(task_instance)"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/base.py"", line 126, in async_process"
"2024-03-25T22:26:43.353Z","processor.async_process()"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/decorators.py"", line 251, in async_process_partial_response"
"2024-03-25T22:26:43.353Z","return async_process_partial_response("
"2024-03-25T22:26:43.353Z","File ""/var/task/categorizer.py"", line 103, in handler"
"2024-03-25T22:26:43.353Z","response = request_handler(event, lambda_context)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py"", line 188, in handle_event_request"
"2024-03-25T22:26:43.353Z","handle_event_request("
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py"", line 499, in run"
"2024-03-25T22:26:43.353Z","bootstrap.run(app_root, handler, lambda_runtime_api_addr)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/__main__.py"", line 21, in main"
"2024-03-25T22:26:43.353Z","awslambdaricmain.main([os.environ[""LAMBDA_TASK_ROOT""], os.environ[""_HANDLER""]])"
"2024-03-25T22:26:43.353Z","File ""/var/runtime/bootstrap.py"", line 60, in main"
"2024-03-25T22:26:43.353Z","main()"
"2024-03-25T22:26:43.353Z","File ""/var/runtime/bootstrap.py"", line 63, in <module>"
"2024-03-25T22:26:43.353Z","source_traceback: Object created at (most recent call last):"
"2024-03-25T22:26:43.353Z","connector: <aiohttp.connector.TCPConnector object at 0x7fdf32456f50>"
"2024-03-25T22:26:43.353Z","connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7fdf1a99a970>, 331.795931377)]']"
"2024-03-25T22:26:43.353Z","[ERROR] 2024-03-25T22:26:43.353Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Unclosed connector"
"2024-03-25T22:26:43.353Z","self.session = aiohttp.ClientSession("
"2024-03-25T22:26:43.353Z","File ""/var/task/stream_chat/async_chat/client.py"", line 66, in __init__"
"2024-03-25T22:26:43.353Z","client = StreamChatAsync("
"2024-03-25T22:26:43.353Z","File ""/var/task/helpers/streamchat_client.py"", line 18, in __init__"
"2024-03-25T22:26:43.353Z","stream_client = StreamChatClient(completionRequested.conversation.channelId)"
"2024-03-25T22:26:43.353Z","File ""/var/task/categorizer.py"", line 56, in async_record_handler"
"2024-03-25T22:26:43.353Z","result = await self.handler(record=data)"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/base.py"", line 649, in _async_process_record"
"2024-03-25T22:26:43.353Z","self._context.run(self._callback, *self._args)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/events.py"", line 84, in _run"
"2024-03-25T22:26:43.353Z","handle._run()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 1928, in _run_once"
"2024-03-25T22:26:43.353Z","self._run_once()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 608, in run_forever"
"2024-03-25T22:26:43.353Z","self.run_forever()"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/asyncio/base_events.py"", line 641, in run_until_complete"
"2024-03-25T22:26:43.353Z","return loop.run_until_complete(task_instance)"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/base.py"", line 126, in async_process"
"2024-03-25T22:26:43.353Z","processor.async_process()"
"2024-03-25T22:26:43.353Z","File ""/var/task/aws_lambda_powertools/utilities/batch/decorators.py"", line 251, in async_process_partial_response"
"2024-03-25T22:26:43.353Z","return async_process_partial_response("
"2024-03-25T22:26:43.353Z","File ""/var/task/categorizer.py"", line 103, in handler"
"2024-03-25T22:26:43.353Z","response = request_handler(event, lambda_context)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py"", line 188, in handle_event_request"
"2024-03-25T22:26:43.353Z","handle_event_request("
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py"", line 499, in run"
"2024-03-25T22:26:43.353Z","bootstrap.run(app_root, handler, lambda_runtime_api_addr)"
"2024-03-25T22:26:43.353Z","File ""/var/lang/lib/python3.11/site-packages/awslambdaric/__main__.py"", line 21, in main"
"2024-03-25T22:26:43.353Z","awslambdaricmain.main([os.environ[""LAMBDA_TASK_ROOT""], os.environ[""_HANDLER""]])"
"2024-03-25T22:26:43.353Z","File ""/var/runtime/bootstrap.py"", line 60, in main"
"2024-03-25T22:26:43.353Z","main()"
"2024-03-25T22:26:43.353Z","File ""/var/runtime/bootstrap.py"", line 63, in <module>"
"2024-03-25T22:26:43.353Z","source_traceback: Object created at (most recent call last):"
"2024-03-25T22:26:43.353Z","client_session: <aiohttp.client.ClientSession object at 0x7fdf1c022190>"
"2024-03-25T22:26:43.353Z","[ERROR] 2024-03-25T22:26:43.353Z 2f7ab88d-c683-46f7-b6dc-616ab9f3241f Unclosed client session"
"2024-03-25T22:26:42.930Z","[WARNING] 2024-03-25T22:26:42.930Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Could not send typing start event to stream chat - StreamChat error code 16: SendEvent failed with error: ""Can't find channel with id"""""
"2024-03-25T22:26:42.911Z","[INFO] 2024-03-25T22:26:42.911Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Sending typing start event to stream chat channel"
"2024-03-25T22:26:42.908Z","[INFO] 2024-03-25T22:26:42.908Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Received 1 records."
"2024-03-25T22:26:42.908Z","[INFO] 2024-03-25T22:26:42.908Z 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Starting handler..."
"2024-03-25T22:26:42.907Z","START RequestId: 2f7ab88c-b683-46f7-b6dc-616ab9f3241f Version: 75"
- Langage dominant
- Python
- Étoiles
- 73
- Forks
- 20
- Merge moyen
- 11 h 34 min
- PR mergées (30 j)
- 7
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de GetStream/stream-chat-python
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
GetStream/stream-chat-python#252 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
GetStream/stream-chat-python#244 ·
-
enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
GetStream/stream-chat-python#167 · 5 commentaires ·
-
conda?Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
GetStream/stream-chat-python#152 ·
-
Add a new way to query all usersOuverte
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
GetStream/stream-chat-python#151 ·
Toutes les issues de GetStream/stream-chat-python
Issues similaires
-
bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
NatLabRockies/openstudio-mcp#286 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
intersystems/ipm#1338 ·
Les mainteneurs répondent en général sous 1 jour
-
separate_packages splits imports from the same explicitly configured packagePeut-être pris @rahul05ranjan l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 2 jours
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOuvertev1
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour