2

I have some code running in a thread that I need to respond to any exceptions within the calling thread. How would I find out if there are any exceptions and just reboot the child thread?

Jonny Flowers
  • 631
  • 1
  • 9
  • 20

2 Answers2

3

You would have to terminate/join the child-process in the try/except/finaly-block of the parent thread and afterwards reinvoke it.

Link to an older SO-post, which discusses the "killing" of a thread.

Community
  • 1
  • 1
Don Question
  • 11,227
  • 5
  • 36
  • 54
2

you can get exception with sth like this:

def run(self):
        while True:                
            try: #yourThread
            except Exception, e: print e

and for restarting a child check out this answer here.

Community
  • 1
  • 1
urcm
  • 2,274
  • 1
  • 19
  • 45