blob: 9c655a58e93f1f67442312bdf7107febdc135037 [file] [log] [blame]
kelvin-onlab54400a92015-02-26 18:05:51 -08001#!/usr/bin/env python
kelvin-onlab54400a92015-02-26 18:05:51 -08002
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07003"""
4Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07005
6Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
7the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
8or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
9
10 TestON is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070013 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070014
15 TestON is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with TestON. If not, see <http://www.gnu.org/licenses/>.
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070022"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070023import threading
Jon Hall65844a32015-03-09 19:09:37 -070024
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070025
Jon Hall65844a32015-03-09 19:09:37 -070026class Thread( threading.Thread ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070027
Jon Hall65844a32015-03-09 19:09:37 -070028 def __init__( self, target=None, threadID=None, name="", args=(),
29 kwargs={} ):
30 super( Thread, self ).__init__()
kelvin-onlab54400a92015-02-26 18:05:51 -080031 self.threadID = threadID
32 self.name = name
33 self.target = target
34 self.args = args
35 self.kwargs = kwargs
36 self.result = None
37
38 def run( self ):
39 try:
40 if self.target is not None:
Jon Hall65844a32015-03-09 19:09:37 -070041 self.result = self.target( *self.args, **self.kwargs )
kelvin-onlab54400a92015-02-26 18:05:51 -080042 except Exception as e:
Jon Hall79bec222015-04-30 16:23:30 -070043 print "ThreadID:" + str( self.threadID ) + ", Name:" +\
44 self.name + "- something went wrong with " +\
45 str( self.target.im_class ) + "." +\
46 str( self.target.im_func ) + " method: "
kelvin-onlab54400a92015-02-26 18:05:51 -080047 print e