Back to index

apport  2.4
Public Member Functions | Private Attributes
apport.REThread.REThread Class Reference

List of all members.

Public Member Functions

def __init__
def run
def return_value
def exc_info
def exc_raise

Private Attributes

 __target
 __args
 __kwargs
 _retval
 _exception

Detailed Description

Thread with return values and exception propagation.

Definition at line 15 of file REThread.py.


Constructor & Destructor Documentation

def apport.REThread.REThread.__init__ (   self,
  group = None,
  target = None,
  name = None,
  args = (),
  kwargs = {},
  verbose = None 
)
Initialize Thread, identical to threading.Thread.__init__().

Definition at line 19 of file REThread.py.

00019 
00020                  verbose=None):
00021         '''Initialize Thread, identical to threading.Thread.__init__().'''
00022 
00023         threading.Thread.__init__(self, group, target, name, args, kwargs, verbose)
00024         self.__target = target
00025         self.__args = args
00026         self.__kwargs = kwargs
00027         self._retval = None
00028         self._exception = None


Member Function Documentation

Return (type, value, traceback) of the exception caught in run().

Definition at line 49 of file REThread.py.

00049 
00050     def exc_info(self):
00051         '''Return (type, value, traceback) of the exception caught in run().'''
00052 
00053         return self._exception

Raise the exception caught in the thread.

Do nothing if no exception was caught.

Definition at line 54 of file REThread.py.

00054 
00055     def exc_raise(self):
00056         '''Raise the exception caught in the thread.
00057 
00058         Do nothing if no exception was caught.
00059         '''
00060         if self._exception:
00061             # there is no syntax which both Python 2 and 3 parse, so we need a
00062             # hack using exec() here
00063             # Python 3:
00064             if sys.version > '3':
00065                 raise self._exception[0](self._exception[1]).with_traceback(self._exception[2])
00066             else:
00067                 exec('raise self._exception[0], self._exception[1], self._exception[2]')
Return value from target function.

This can only be called after the thread has finished, i. e. when
isAlive() is False and did not terminate with an exception.

Definition at line 39 of file REThread.py.

00039 
00040     def return_value(self):
00041         '''Return value from target function.
00042 
00043         This can only be called after the thread has finished, i. e. when
00044         isAlive() is False and did not terminate with an exception.
00045         '''
00046         assert not self.isAlive()
00047         assert not self._exception
00048         return self._retval

Run target function, identical to threading.Thread.run().

Definition at line 29 of file REThread.py.

00029 
00030     def run(self):
00031         '''Run target function, identical to threading.Thread.run().'''
00032 
00033         if self.__target:
00034             try:
00035                 self._retval = self.__target(*self.__args, **self.__kwargs)
00036             except:
00037                 if sys:
00038                     self._exception = sys.exc_info()


Member Data Documentation

Definition at line 24 of file REThread.py.

Definition at line 25 of file REThread.py.

Definition at line 23 of file REThread.py.

Definition at line 27 of file REThread.py.

Definition at line 26 of file REThread.py.


The documentation for this class was generated from the following file: