1818import multiprocessing
1919
2020from abc import abstractmethod , ABC
21- from typing import Any , Dict , Optional , Tuple , List , Set , Generic , TypeVar , Union
21+ from typing import TYPE_CHECKING , Dict , Optional , Tuple , List , Set , Generic , TypeVar , Union
2222
2323from ...common .logger import Logger
2424from ...common .types import Readables , SelectableEvents , Writables
2525from ...common .constants import DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT , DEFAULT_SELECTOR_SELECT_TIMEOUT
2626from ...common .constants import DEFAULT_WAIT_FOR_TASKS_TIMEOUT
2727
2828from ..connection import TcpClientConnection , UpstreamConnectionPool
29- from ..event import eventNames , EventQueue
29+ from ..event import eventNames
3030
31- from .work import Work
31+ if TYPE_CHECKING :
32+ from typing import Any
33+
34+ from ..event import EventQueue
35+ from .work import Work
3236
3337T = TypeVar ('T' )
3438
@@ -62,7 +66,7 @@ def __init__(
6266 iid : str ,
6367 work_queue : T ,
6468 flags : argparse .Namespace ,
65- event_queue : Optional [EventQueue ] = None ,
69+ event_queue : Optional [' EventQueue' ] = None ,
6670 ) -> None :
6771 super ().__init__ ()
6872 self .iid = iid
@@ -71,7 +75,7 @@ def __init__(
7175 self .event_queue = event_queue
7276
7377 self .running = multiprocessing .Event ()
74- self .works : Dict [int , Work [Any ]] = {}
78+ self .works : Dict [int , ' Work[Any]' ] = {}
7579 self .selector : Optional [selectors .DefaultSelector ] = None
7680 # If we remove single quotes for typing hint below,
7781 # runtime exceptions will occur for < Python 3.9.
0 commit comments