You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def test_acompletion_resource_cleanup(end):
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
# Make an async completion call
cnt = 1
async for el in await litellm.acompletion(
model="deepseek/deepseek-chat",
api_key="...",
base_url="https://api.deepseek.com/v1",
messages=[
{
"role": "user",
"content": "一次不差的复述下下方短文内容:在这个信息爆炸的时代,静下心来读一本书,成了一种奢侈。手机、社交媒体、短视频接连不断地抢占我们的注意力,使我们越来越难以集中精力去做一件事情。很多人开始感到焦虑,仿佛每天都很忙,却不知忙了些什么。其实,我们真正需要的,是一种“慢下来”的勇气。在快节奏的生活中,抽出时间去散步、阅读、与亲人交流,这些看似平凡的小事,恰恰是我们获得内心安宁的关键。当我们暂时放下外界的喧嚣,才更容易听见内心的声音。慢,不是懒惰,而是一种自我掌控的表现。它让我们重新掌握生活的节奏,不再被外界牵着走。因此,学会在忙碌中寻找片刻的安静,是每个人都该修炼的生活智慧。",
}
],
stream=True,
):
print(f"{end} {el}")
# await asyncio.sleep(10)
if end:
cnt += 1
if cnt > 3:
break # End an async for early
# await litellm.close_litellm_async_clients()
# lsof -i @api.deepseek.com | grep -c "https"
resource_warnings = [
warning
for warning in w
if "Unclosed" in str(warning.message)
and (
"client session" in str(warning.message)
or "connector" in str(warning.message)
)
]
assert (
len(resource_warnings) == 0
), f"Found unclosed resources: {[str(w.message) for w in resource_warnings]}"
async def main():
# Run the test
await test_acompletion_resource_cleanup(True)
# await test_acompletion_resource_cleanup(False)
print("✅ All tests passed!")
# Run the tests concurrently
# await asyncio.gather(
# test_acompletion_resource_cleanup(True),
# test_acompletion_resource_cleanup(False)
# )
# print("✅ All tests passed!")
if __name__ == "__main__":
asyncio.run(main())
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions