You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 08:20:49 UTC

[buildstream] 19/33: TEMP: MultiprocessingPdb, traceback in Job._child_action

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

tvb pushed a commit to branch aevri/picklable_jobs
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 684c1b96da60360439565bed405eb3228ab5ce3b
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Tue Apr 2 13:22:51 2019 +0100

    TEMP: MultiprocessingPdb, traceback in Job._child_action
---
 src/buildstream/_scheduler/jobs/elementjob.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/buildstream/_scheduler/jobs/elementjob.py b/src/buildstream/_scheduler/jobs/elementjob.py
index a684235..ca19273 100644
--- a/src/buildstream/_scheduler/jobs/elementjob.py
+++ b/src/buildstream/_scheduler/jobs/elementjob.py
@@ -91,6 +91,18 @@ def make_element_from_picklable_element_state(state):
     print("Unpickled element", element, repr(element))
     return element
 
+import sys
+import pdb
+
+class MultiprocessingPdb(pdb.Pdb):
+    def interaction(self, *args, **kwargs):
+        _stdin = sys.stdin
+        try:
+            sys.stdin = open('/dev/stdin')
+            pdb.Pdb.interaction(self, *args, **kwargs)
+        finally:
+            sys.stdin = _stdin
+
 # ElementJob()
 #
 # A job to run an element's commands. When this job is spawned
@@ -184,7 +196,15 @@ class ChildElementJob(ChildJob):
                      detail=env_dump)
 
         # Run the action
-        return self._action_cb(self._element)
+        # MultiprocessingPdb().set_trace()
+        try:
+            result = self._action_cb(self._element)
+        except Exception as e:
+            print(e)
+            import traceback
+            traceback.print_exc()
+            raise
+        return result
 
     def child_process_data(self):
         data = {}