You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/02/10 07:14:21 UTC
[GitHub] [superset] villebro commented on a change in pull request #13041: fix: timeout decorator on Windows
villebro commented on a change in pull request #13041:
URL: https://github.com/apache/superset/pull/13041#discussion_r573494677
##########
File path: superset/utils/core.py
##########
@@ -749,6 +752,34 @@ def __exit__( # pylint: disable=redefined-outer-name,unused-variable,redefined-
logger.exception(ex)
+class TimerTimeout:
+ def __init__(self, seconds: int = 1, error_message: str = "Timeout") -> None:
+ self.seconds = seconds
+ self.error_message = error_message
+ self.timer = threading.Timer(seconds, _thread.interrupt_main)
+
+ def __enter__(self) -> None:
+ self.timer.start()
+
+ def __exit__( # pylint: disable=redefined-outer-name,unused-variable,redefined-builtin
+ self, type: Any, value: Any, traceback: TracebackType
+ ) -> None:
+ self.timer.cancel()
+ if type is KeyboardInterrupt: # raised by _thread.interrupt_main
Review comment:
Surprised that this is a `KeyboardInterrupt`
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org