You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:30:19 UTC

[buildstream] 11/21: WIP: bst-job-replay

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch aevri/win32
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 276b47de424cf35b0df80d48604b323df06e0a9e
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Thu Apr 11 10:49:32 2019 +0100

    WIP: bst-job-replay
---
 setup.py                               |  3 ++-
 src/buildstream/_jobreplay.py          | 15 +++++++++++++++
 src/buildstream/_scheduler/jobs/job.py |  5 +++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index ab3c6f3..af81886 100755
--- a/setup.py
+++ b/setup.py
@@ -152,7 +152,8 @@ bst_install_entry_points = {
 if not os.environ.get('BST_ARTIFACTS_ONLY', ''):
     check_for_bwrap()
     bst_install_entry_points['console_scripts'] += [
-        'bst = buildstream._frontend:cli'
+        'bst = buildstream._frontend:cli',
+        'bst-job-replay = buildstream._jobreplay:cli',
     ]
 
 #####################################################
diff --git a/src/buildstream/_jobreplay.py b/src/buildstream/_jobreplay.py
new file mode 100644
index 0000000..1c05324
--- /dev/null
+++ b/src/buildstream/_jobreplay.py
@@ -0,0 +1,15 @@
+import multiprocessing
+
+import click
+
+from ._scheduler.jobs.job import _unpickle_child_job
+
+
+@click.command(name='bst-job-replay', short_help="Replay a bst job")
+@click.argument('replayfile', type=click.File("rb"))
+def cli(replayfile):
+    job = _unpickle_child_job(replayfile)
+    queue = multiprocessing.Queue()
+    job._queue = queue
+    job._scheduler_context.set_message_handler(job._child_message_handler)
+    job.child_process()
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index ebbbfa6..3b228bc 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -24,6 +24,7 @@ import enum
 import copyreg
 import io
 import os
+import pathlib
 import pickle
 import sys
 import signal
@@ -162,6 +163,10 @@ def _pickle_child_job(child_job, context):
     pickler.dump(child_job)
     data.seek(0)
 
+    path = f"{child_job.action_name}_{child_job._task_id}"
+    with open(path, "wb") as f:
+        f.write(data.getvalue())
+
     return data