Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify return_code interface for task runner #24093

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion airflow/task/task_runner/base_task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def start(self):
"""Start running the task instance in a subprocess."""
raise NotImplementedError()

def return_code(self) -> Optional[int]:
def return_code(self, timeout: int = 0) -> Optional[int]:
"""
:return: The return code associated with running the task instance or
None if the task is not yet done.
Expand Down
3 changes: 2 additions & 1 deletion airflow/task/task_runner/cgroup_task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import datetime
import os
import uuid
from typing import Optional

import psutil
from cgroupspy import trees
Expand Down Expand Up @@ -163,7 +164,7 @@ def start(self):
self.log.debug("Starting task process with cgroups cpu,memory: %s", cgroup_name)
self.process = self.run_command(['cgexec', '-g', f'cpu,memory:{cgroup_name}'])

def return_code(self):
def return_code(self, timeout: int = 0) -> Optional[int]:
return_code = self.process.poll()
# TODO(plypaul) Monitoring the control file in the cgroup fs is better than
# checking the return code here. The PR to use this is here:
Expand Down