blob: fcc06b55dab2182fd8efe3fb556418b1d50682a5 [file] [log] [blame]
kelvin-onlab54400a92015-02-26 18:05:51 -08001#!/usr/bin/env python
2import threading
3
Jon Hall65844a32015-03-09 19:09:37 -07004
5class Thread( threading.Thread ):
6 def __init__( self, target=None, threadID=None, name="", args=(),
7 kwargs={} ):
8 super( Thread, self ).__init__()
kelvin-onlab54400a92015-02-26 18:05:51 -08009 self.threadID = threadID
10 self.name = name
11 self.target = target
12 self.args = args
13 self.kwargs = kwargs
14 self.result = None
15
16 def run( self ):
17 try:
18 if self.target is not None:
Jon Hall65844a32015-03-09 19:09:37 -070019 self.result = self.target( *self.args, **self.kwargs )
kelvin-onlab54400a92015-02-26 18:05:51 -080020 except Exception as e:
Jon Hall79bec222015-04-30 16:23:30 -070021 print "ThreadID:" + str( self.threadID ) + ", Name:" +\
22 self.name + "- something went wrong with " +\
23 str( self.target.im_class ) + "." +\
24 str( self.target.im_func ) + " method: "
kelvin-onlab54400a92015-02-26 18:05:51 -080025 print e