generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 424
Open
Labels
area-asyncRelated to asynchronous flows or multi-threadingRelated to asynchronous flows or multi-threadingbugSomething isn't workingSomething isn't working
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.3.0
Python Version
3.13.2
Operating System
Mac 15.1.1
Installation Method
pip
Steps to Reproduce
Start concurrency job with concurrent.futures.ThreadPoolExecutor
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = {
executor.submit(process_paragraph, model, config, paragraph): idx
for idx, paragraph in enumerate(paragraphs)
}
in process_paragraph
function build up agent
def process_paragraph():
agent = Agent(model,config...)
agent(msg)
....
in fact, process_paragraph is a flow to process messages.
Expected Behavior
I don't know why or should we have any interface to release connection after a talk is completed?
or any API for me to release the connection manually in code?
Actual Behavior
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1500, in _request
response = await self._client.send(
^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpx/_client.py", line 1629, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpx/_client.py", line 1657, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpx/_client.py", line 1694, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpx/_client.py", line 1730, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpx/_transports/default.py", line 394, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pool_request.request
^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/anyio/streams/tls.py", line 216, in aclose
await self.transport_stream.aclose()
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 1314, in aclose
self._transport.close()
~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/selector_events.py", line 1205, in close
super().close()
~~~~~~~~~~~~~^^
File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/selector_events.py", line 865, in close
self._loop.call_soon(self._call_connection_lost, None)
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 833, in call_soon
self._check_closed()
~~~~~~~~~~~~~~~~~~^^
File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 556, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
File "/Users/yuanyi/OpenSource/ArxivAutoJob/deepSeekmodel.py", line 280, in stream
response = await self.client.chat.completions.create(**request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/resources/chat/completions/completions.py", line 2000, in create
return await self._post(
^^^^^^^^^^^^^^^^^
...<43 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1767, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1461, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1524, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1594, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1524, in _request
return await self._retry_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<6 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1594, in _retry_request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
)
^
File "/Users/yuanyi/OpenSource/ArxivAutoJob/.venv/lib/python3.13/site-packages/openai/_base_client.py", line 1534, in _request
raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
Additional Context
No response
Possible Solution
No response
Related Issues
No response
Metadata
Metadata
Assignees
Labels
area-asyncRelated to asynchronous flows or multi-threadingRelated to asynchronous flows or multi-threadingbugSomething isn't workingSomething isn't working