Skip to content

Commit 68ea92d

Browse files
committed
chore: reset thread name after coroutine is done
1 parent 16b56b0 commit 68ea92d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

robotcode/utils/async_tools.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ async def create_inner_task(coro: Callable[..., Coroutine[Any, Any, _T]], *args:
318318
return await inner_task
319319

320320
def run(coro: Callable[..., Coroutine[Any, Any, _T]], *args: Any, **kwargs: Any) -> _T:
321+
old_name = threading.current_thread().name
321322
threading.current_thread().name = coro.__qualname__
322-
323-
return asyncio.run(create_inner_task(coro, *args, **kwargs))
323+
try:
324+
return asyncio.run(create_inner_task(coro, *args, **kwargs))
325+
finally:
326+
threading.current_thread().name = old_name
324327

325328
cti = get_current_future_info()
326329
result = run_in_thread(run, coro, *args, **kwargs)

0 commit comments

Comments
 (0)