2121import weakref
2222from enum import Enum
2323from queue import Queue
24- from typing import Callable , Optional , TypedDict , Union
24+ from typing import Any , Callable , Coroutine , Optional , TypedDict , Union
2525
2626logger = logging .getLogger (__name__ )
2727
@@ -54,7 +54,9 @@ class ConversationMessage(TypedDict):
5454class ManagedThread (threading .Thread ):
5555 def __init__ (
5656 self ,
57- task : Optional [Union [Callable [..., bool ], weakref .WeakMethod ]],
57+ task : Optional [
58+ Union [Callable [..., Coroutine [Any , Any , bool ]], weakref .WeakMethod ]
59+ ],
5860 error_queue : Optional [Queue ] = None ,
5961 name : Optional [str ] = None ,
6062 loop : Optional [asyncio .AbstractEventLoop ] = None ,
@@ -74,7 +76,9 @@ def set_loop(self, loop: asyncio.AbstractEventLoop):
7476
7577 def run (self ):
7678 while not self .stop_event .is_set ():
77- task : Optional [Union [Callable [..., bool ], weakref .WeakMethod ]] = self .task
79+ task : Optional [
80+ Union [Callable [..., Coroutine [Any , Any , bool ]], weakref .WeakMethod ]
81+ ] = self .task
7882 if isinstance (task , weakref .WeakMethod ):
7983 task = task ()
8084 if task is None :
0 commit comments