forked from phoenix-oss/llama-stack-mirror
fix(library_client): ensure pending asyncio tasks like generator athrow are executed
This commit is contained in:
parent
ba917a9c48
commit
70ff226b6a
1 changed files with 3 additions and 1 deletions
|
@ -163,6 +163,9 @@ class LlamaStackAsLibraryClient(LlamaStackClient):
|
||||||
except StopAsyncIteration:
|
except StopAsyncIteration:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
pending = asyncio.all_tasks(loop)
|
||||||
|
if pending:
|
||||||
|
loop.run_until_complete(asyncio.gather(*pending, return_exceptions=True))
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
return sync_generator()
|
return sync_generator()
|
||||||
|
@ -383,7 +386,6 @@ class AsyncLlamaStackAsLibraryClient(AsyncLlamaStackClient):
|
||||||
|
|
||||||
# Wrap the generator to preserve context across iterations
|
# Wrap the generator to preserve context across iterations
|
||||||
wrapped_gen = preserve_headers_context_async_generator(gen())
|
wrapped_gen = preserve_headers_context_async_generator(gen())
|
||||||
|
|
||||||
mock_response = httpx.Response(
|
mock_response = httpx.Response(
|
||||||
status_code=httpx.codes.OK,
|
status_code=httpx.codes.OK,
|
||||||
content=wrapped_gen,
|
content=wrapped_gen,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue