casra-developers commented on a change in pull request #16110:
URL: https://github.com/apache/airflow/pull/16110#discussion_r651460996
##########
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:
Thanks for explaining. I was not familiar with mypy but this seems very
useful also for future projects :)
I have commited the change request and there is now an Optional annotation.
##########
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:
Thanks for explaining. I was not familiar with mypy but this seems very
useful also for future projects :)
I have comited the change request and there is now an Optional annotation.
--
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:
[email protected]