Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions metaflow/plugins/cards/card_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ def resolve_card(
@contextmanager
def timeout(time):
# Register a function to raise a TimeoutError on the signal.
signal.signal(signal.SIGALRM, raise_timeout)
# Schedule the signal to be sent after ``time``.
signal.alarm(time)
import sys
if sys.platform == "win32":
raise RuntimeError(
"Card timeout is not supported on Windows (SIGALRM is POSIX-only)."
)
signal.signal(signal.SIGALRM, raise_timeout)
signal.alarm(time)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated

try:
yield
Expand Down
11 changes: 9 additions & 2 deletions metaflow/plugins/timeout_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,15 @@ def task_pre_step(
if ubf_context != UBF_CONTROL and retry_count <= max_user_code_retries:
# enable timeout only when executing user code
self.step_name = step_name
signal.signal(signal.SIGALRM, self._sigalrm_handler)
signal.alarm(self.secs)
import sys
if sys.platform == "win32":
raise MetaflowException(
"@timeout is not supported on Windows because it relies on "
"POSIX signals (SIGALRM). Use a Linux-based compute backend "
"(e.g. @kubernetes or @batch) to use @timeout."
)
signal.signal(signal.SIGALRM, self._sigalrm_handler)
signal.alarm(self.secs)
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated

def task_post_step(
self, step_name, flow, graph, retry_count, max_user_code_retries
Expand Down