StreamChatAsync does not clean up resources according to httpaio
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne mit der Untersuchung von stream_chat/async_chat/client.py, insbesondere der Erstellung von ClientSession und dem Bereinigungspfad aexit. Reproduziere das im Issue beschriebene AWS-Lambda- oder AsyncBatchProcessor-Szenario und verfolge die Warnungen zu nicht geschlossenen Sitzungen und nicht geschlossenen Konnektoren. Als erledigt gilt die Aufgabe, wenn die gemeldete Nutzung diese Ressourcenwarnungen nicht mehr ausgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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"
- Vorherrschende Sprache
- Python
- Sterne
- 73
- Forks
- 20
- Ø Merge
- 11 Std. 34 Min.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus GetStream/stream-chat-python
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
GetStream/stream-chat-python#252 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 42/100
GetStream/stream-chat-python#244 ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
GetStream/stream-chat-python#167 · 5 Kommentare ·
-
conda?Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
GetStream/stream-chat-python#152 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
GetStream/stream-chat-python#151 ·
Alle Issues in GetStream/stream-chat-python
Ähnliche Issues
-
bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
intersystems/ipm#1338 ·
Maintainer antworten meist innerhalb von 1 Tag
-
separate_packages splits imports from the same explicitly configured packageEvtl. vergeben @rahul05ranjan hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 2 Tagen
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOffenv1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag