def __init__(self, on_exit: ExitOption=ExitOption.ABANDON) -> None:
"""
Init the state.
Args:
on_exit: determines the behavior on exit when the executor is used as a context manager
ExitOption.ABANDON: this is the default. All remaining threads are abandoned.
ExitOption.NO_WAIT: shuts down without waiting for remaining threads to complete.
ExitOption.WAIT: shuts down and waits for remaining threads to complete. This is the
default behavior for a vanilla `futures.Executor`, but not for `ThreadExecutor`.
Returns: None
Raises: None
Required Tests: None
"""
# shared state
self._monitored_threads = {} # type: dict
self._monitor_thread = None # type: Optional[threading.Thread]
# lock for ^
self._monitored_thread_lock = threading.RLock()
# main thread state
self._is_shutdown = False
self._abandon = False
self._on_exit = on_exit
评论列表
文章目录