Common initialization for all BackgroundJob objects
(self)
| 386 | raise NotImplementedError("This class can not be instantiated directly.") |
| 387 | |
| 388 | def _init(self): |
| 389 | """Common initialization for all BackgroundJob objects""" |
| 390 | |
| 391 | for attr in ['call','strform']: |
| 392 | assert hasattr(self,attr), "Missing attribute <%s>" % attr |
| 393 | |
| 394 | # The num tag can be set by an external job manager |
| 395 | self.num = None |
| 396 | |
| 397 | self.status = BackgroundJobBase.stat_created |
| 398 | self.stat_code = BackgroundJobBase.stat_created_c |
| 399 | self.finished = False |
| 400 | self.result = '<BackgroundJob has not completed>' |
| 401 | |
| 402 | # reuse the ipython traceback handler if we can get to it, otherwise |
| 403 | # make a new one |
| 404 | try: |
| 405 | make_tb = get_ipython().InteractiveTB.text |
| 406 | except: |
| 407 | make_tb = AutoFormattedTB(mode = 'Context', |
| 408 | color_scheme='NoColor', |
| 409 | tb_offset = 1).text |
| 410 | # Note that the actual API for text() requires the three args to be |
| 411 | # passed in, so we wrap it in a simple lambda. |
| 412 | self._make_tb = lambda : make_tb(None, None, None) |
| 413 | |
| 414 | # Hold a formatted traceback if one is generated. |
| 415 | self._tb = None |
| 416 | |
| 417 | threading.Thread.__init__(self) |
| 418 | |
| 419 | def __str__(self): |
| 420 | return self.strform |
no test coverage detected