fix: add await to to_thread call (#3558)
* refactor(tracing/service.py): change asyncio.create_task to self.logs_queue.put_nowait for better performance and readability * fix(chat.py): remove unnecessary logging of exception in build_flow function to improve code readability and maintainability * refactor(tracing/service.py): refactor _end_and_reset method to use asyncio.create_task for better performance and readability
This commit is contained in:
parent
c773d5c20c
commit
60c586a52b
2 changed files with 2 additions and 3 deletions
|
|
@ -329,8 +329,7 @@ async def build_flow(
|
|||
build_task = asyncio.create_task(await asyncio.to_thread(_build_vertex, vertex_id, graph))
|
||||
try:
|
||||
await build_task
|
||||
except asyncio.CancelledError as exc:
|
||||
logger.exception(exc)
|
||||
except asyncio.CancelledError:
|
||||
build_task.cancel()
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class TracingService(Service):
|
|||
self._end_traces(trace_id, trace_name, e)
|
||||
raise e
|
||||
finally:
|
||||
asyncio.create_task(asyncio.to_thread(self._end_and_reset, trace_id, trace_name, None))
|
||||
asyncio.create_task(await asyncio.to_thread(self._end_and_reset, trace_id, trace_name, None))
|
||||
|
||||
async def _end_and_reset(self, trace_id: str, trace_name: str, error: Exception | None = None):
|
||||
self._end_traces(trace_id, trace_name, error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue