Re-raise Python exception and preserve stack trace

后端 未结 3 1270
刺人心
刺人心 2020-12-13 17:15

I\'m trying to catch an exception in a thread and re-raise it in the main thread:

import threading
import sys

class F         


        
3条回答
  •  心在旅途
    2020-12-13 17:34

    Could you write it somewhat like this:

    try:
        raise ValueError('x')
    except ValueError as ex:
        self.exc_info = ex
    

    and then use the stacktrace from the exception?

提交回复
热议问题