From 65e1775fd380b7e6b67a88c327f8961929e9cafb Mon Sep 17 00:00:00 2001 From: Daniel Biehl Date: Fri, 22 Dec 2023 00:12:23 +0100 Subject: [PATCH] refactor: remove some unneeded code --- packages/core/src/robotcode/core/async_tools.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/core/src/robotcode/core/async_tools.py b/packages/core/src/robotcode/core/async_tools.py index 5e79acd54..4d58253bd 100644 --- a/packages/core/src/robotcode/core/async_tools.py +++ b/packages/core/src/robotcode/core/async_tools.py @@ -24,16 +24,15 @@ List, MutableSet, Optional, - Protocol, Set, Type, TypeVar, Union, cast, - runtime_checkable, ) -from robotcode.core.utils.inspect import ensure_coroutine +from .utils.inspect import ensure_coroutine +from .utils.threading import is_threaded_callable _T = TypeVar("_T") @@ -155,11 +154,6 @@ def __init__(self, _func: _TCallable) -> None: super().__init__(_func, AsyncEvent[_TCallable, Any]) -@runtime_checkable -class HasThreaded(Protocol): - __threaded__: bool - - class AsyncTaskingEventResultIteratorBase(AsyncEventResultIteratorBase[_TCallable, _TResult]): def __init__(self, *, task_name_prefix: Optional[str] = None) -> None: super().__init__() @@ -189,8 +183,8 @@ def _done(f: asyncio.Future[_TResult]) -> None: set(self), ): if method is not None: - if threaded and isinstance(method, HasThreaded) and method.__threaded__: # type: ignore - future = run_coroutine_in_thread(ensure_coroutine(method), *args, **kwargs) # type: ignore + if threaded and is_threaded_callable(method): + future = run_coroutine_in_thread(ensure_coroutine(method), *args, **kwargs) else: future = create_sub_task(ensure_coroutine(method)(*args, **kwargs)) awaitables.append(future)