Skip to content

Pass the default process timeout from the main process to the subprocesses that build the projects #693

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

Merged
merged 1 commit into from
Aug 10, 2022
Merged
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
12 changes: 11 additions & 1 deletion project.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,16 @@ def included(self, subtarget):
def new_result(self):
return ProjectListResult()

def start_process(self, project_subbuilder, default_timeout):
"""
Sets the default timeout in the global variable of a newly started subprocess
and builds `project_subbuilder` afterwards.
If we invoked project_subbilder.build() immediately in the new process, it would
not inherit the default timeout from the parent process.
"""
common.set_default_execute_timeout(default_timeout)
project_subbuilder.build()

def build(self, stdout=sys.stdout):
# Setup process pool to submit work to
thread_pool = futures.ProcessPoolExecutor(max_workers=self.processes)
Expand All @@ -1010,7 +1020,7 @@ def build(self, stdout=sys.stdout):
# For each project that needs building, submit a future to build said project
for project in projects_to_build:
project_subbuilder = self.subbuilder.initialize(*([project] + self.payload()))
worker = thread_pool.submit(project_subbuilder.build)
worker = thread_pool.submit(self.start_process, project_subbuilder, common.DEFAULT_EXECUTE_TIMEOUT)
submitted_futures.append(worker)

# Cleanup in main process
Expand Down