robotframework
robotframework copied to clipboard
run robot with multi thread has error: [ ERROR ] Reading XML source 'D:\result\output.xml' failed: Incompatible child element 'statistics' for 'kw'.
robotframework: 6.1.1 python: 3.7.9
hello, when I run robot with multi thread has error: [ ERROR ] Reading XML source 'D:\result\output.xml' failed: Incompatible child element 'statistics' for 'kw'. I start 4 threads to execute run(robot_file_path, outputdir=result_path) at the same time, i get a error message: [ ERROR ] Reading XML source 'D:\result\output.xml' failed: Incompatible child element 'statistics' for 'kw'.
below is my code script:
import threading
from robot import run
class MultiThreadings(object):
def __init__(self):
self.thread = threading
def run(self, robot_file_path, result_path):
run(robot_file_path, outputdir=result_path)
threading_id_str = "thread" + str(self.thread.get_ident())
def multi(self, robot_file_path, result_path):
threads = []
for i in range(0, 4):
t = self.thread.Thread(target=self.run, args=(robot_file_path, result_path + "-" + str(i)))
threads.append(t)
for t in threads:
t.start()
robot_file_path = "./01.robot" result_path = "./result" multi = MultiThreadings() multi.multi(robot_file_path, result_path) print("ok")
I've had the same problem many times. The robot.api.logger
is not thread-safe, you should not call it from different threads, only the MainThread. I'm considering creating a monkeypatch to add a mutex over it.