uranusjr commented on a change in pull request #16110: URL: https://github.com/apache/airflow/pull/16110#discussion_r650763917
########## File path: airflow/utils/timeout.py ########## @@ -22,12 +22,43 @@ from airflow.utils.platform import IS_WINDOWS from airflow.exceptions import AirflowTaskTimeout from airflow.utils.log.logging_mixin import LoggingMixin +from typing import ContextManager, Type -TIMER_THREAD_ATTR = '_timer_thread' +_timeout = ContextManager[None] -class timeout(LoggingMixin): # pylint: disable=invalid-name - """To be used in a ``with`` block and timeout its content.""" +class _timeout_windows(_timeout, LoggingMixin): + + def __init__(self, seconds=1, error_message='Timeout'): + super().__init__() + self._timer: Timer = None Review comment: When youi have `self._timer: Timer`, the right hand side of the assignment must evaluate to a `Timer`, which `None` is not. To make Mypy accept this, you need to annotate the type as `Optional[Timer]` instead. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org