1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
15 from api.utils.influx import write_data_tasklist
18 class DaemonThread(threading.Thread):
20 def __init__(self, method, args):
21 super(DaemonThread, self).__init__(target=method, args=args)
23 self.command_list = args[0]
24 self.task_id = args[1]
27 timestamp = datetime.datetime.now()
30 write_data_tasklist(self.task_id, timestamp, 0)
31 self.method(self.command_list, self.task_id)
32 write_data_tasklist(self.task_id, timestamp, 1)
33 except Exception as e:
34 write_data_tasklist(self.task_id, timestamp, 2, error=str(e))
36 _handle_testsuite_file(self.task_id)
39 def _handle_testsuite_file(task_id):
41 os.remove(os.path.join(conf.TEST_SUITE_PATH, task_id + '.yaml'))
43 if e.errno != errno.ENOENT: