Skip to content

Commit

Permalink
update function name to finalize to gather all tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhe-log10 committed Jun 4, 2024
1 parent d527310 commit 3239e8d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/logging/openai_async_stream_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import openai
from openai import AsyncOpenAI

from log10._httpx_utils import gather_pending_async_tasks
from log10._httpx_utils import finalize
from log10.load import log10


Expand All @@ -20,7 +20,7 @@ async def main():
)
async for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
await gather_pending_async_tasks()
await finalize()


asyncio.run(main())
2 changes: 1 addition & 1 deletion log10/_httpx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
return response


async def gather_pending_async_tasks():
async def finalize():
pending = asyncio.all_tasks()
pending.remove(asyncio.current_task())
await asyncio.gather(*pending)

0 comments on commit 3239e8d

Please sign in to comment.