mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-04-28 03:29:59 +00:00
perf(middleware): await background task cancellation on timeout (#786)
This commit is contained in:
parent
5b57f4ddf3
commit
a0e3d7d192
3 changed files with 8 additions and 5 deletions
|
|
@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|||
|
||||
[project]
|
||||
name = "supermemory-openai-sdk"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
description = "Memory tools for OpenAI function calling with supermemory"
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
|
|
|
|||
|
|
@ -554,9 +554,12 @@ class SupermemoryOpenAIWrapper:
|
|||
f"Background tasks did not complete within {timeout}s timeout"
|
||||
)
|
||||
# Cancel remaining tasks
|
||||
for task in self._background_tasks:
|
||||
if not task.done():
|
||||
task.cancel()
|
||||
tasks_to_cancel = [task for task in self._background_tasks if not task.done()]
|
||||
for task in tasks_to_cancel:
|
||||
task.cancel()
|
||||
|
||||
if tasks_to_cancel:
|
||||
await asyncio.gather(*tasks_to_cancel, return_exceptions=True)
|
||||
raise
|
||||
|
||||
def cancel_background_tasks(self) -> None:
|
||||
|
|
|
|||
2
packages/openai-sdk-python/uv.lock
generated
2
packages/openai-sdk-python/uv.lock
generated
|
|
@ -2427,7 +2427,7 @@ wheels = [
|
|||
|
||||
[[package]]
|
||||
name = "supermemory-openai-sdk"
|
||||
version = "1.0.2"
|
||||
version = "1.0.3"
|
||||
source = { editable = "." }
|
||||
dependencies = [
|
||||
{ name = "openai" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue