Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You mentioned a separate process: if your problem is to capture the traceback in process A and show it in process B, as if the exception was actually raised in the latter, then I'm afraid there is no clean way to do it.</p> <p>I would suggest to serialize the traceback in process A, send it to process B and from there raise a new exception that includes the former in its description. The result is a somewhat longer output, but it carries information about both processes stacks.</p> <p>In the following example there aren't really two separate processes, but I hope it makes my point clearer:</p> <pre><code>import traceback, StringI def functionInProcessA(): raise Exception('Something happened in A') class RemoteException(Exception): def __init__(self, tb): Exception.__init__(self, "Remote traceback:\n\n%s" % tb) def controlProcessB(): try: functionInProcessA() except: fd = StringIO.StringIO() traceback.print_exc(file=fd) tb = fd.getvalue() raise RemoteException(tb) if __name__ == '__main__': controlProcessB() </code></pre> <p>Output:</p> <pre><code>Traceback (most recent call last): File "a.py", line 20, in &lt;module&gt; controlProcessB() File "a.py", line 17, in controlProcessB raise RemoteException(tb) __main__.RemoteException: Remote traceback: Traceback (most recent call last): File "a.py", line 12, in controlProcessB functionInProcessA() File "a.py", line 4, in functionInProcessA raise Exception('Something happened in A') Exception: Something happened in A </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload