Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run robot with multi thread has error: [ ERROR ] Reading XML source 'D:\result\output.xml' failed: Incompatible child element 'statistics' for 'kw'. #5026

Open
ysy1418899560 opened this issue Jan 18, 2024 · 1 comment

Comments

@ysy1418899560
Copy link

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'.

Uploading DD97FFE0-905C-417e-8E06-F68FBCB0C133.png…

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")

@Lenormju
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants