Closed HolQue closed 7 months ago
Addendum:
In opposite to https://github.com/test-fullautomation/robotframework/issues/77 the code above contains no coding error.
But even in this case the results are not stable. I execute the test repeatedly in a Windows console. Sometime the test result is PASS, sometimes the test crashes:
Threading Test | PASS |
------------------------------------------------------------------------------
Test.Threading :: Simple test suite | PASS |
1 test, 1 passed, 0 failed, 0 unknown
Exception in thread TEST_THREAD_2:
==============================================================================
AttributeError: 'NoneType' object has no attribute 'status'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\RobotFramework\python39\lib\threading.py", line 980, in _bootstrap_inner
Output: D:\ROBFW\TestTestcases\RobotFramework\threading\logfiles\test.threading.xml
self.run()
File "D:\RobotFramework\python39\lib\threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "D:\RobotFramework\python39\lib\site-packages\robotframework-6.1-py3.9.egg\robot\running\bodyrunner.py", line 548, in run_worker
self._context.variables.end_thread()
File "D:\RobotFramework\python39\lib\site-packages\robotframework-6.1-py3.9.egg\robot\running\statusreporter.py", line 67, in __exit__
raise failure
robot.errors.HandlerExecutionFailed: AttributeError: 'NoneType' object has no attribute 'status'
Log: D:\ROBFW\TestTestcases\RobotFramework\threading\logfiles\test.threading_log.html
Report: D:\ROBFW\TestTestcases\RobotFramework\threading\logfiles\test.threading_report.html
------------------------------
RF returned ERRORLEVEL : 0
------------------------------
But also in this case the test result is PASS and the error level 0.
A simple FOR loop:
causes the following log output:
It can be seen that the indentation of a start of something is aligned to the indentation of the corresponding end of this something.
Now the same in two threads:
Log output:
The indentation of
START
andEND
is not aligned any more.The file robotframework-6.1-py3.9.egg\robot\output\debugfile.py contains
self._indent
. Seems thatself._indent
does not know about threading. The variable only reacts on the start of something (self._indent += 1
) and the end of something (self._indent -= 1
).And therefore also the start of a new thread (during the lifetime of another thread) increases the indentation:
But because of the parallelism of the threads I would not expect an increased indentation here.
The following log lines in the example above are a mix of the log output of both threads. This causes the indentation being unsynchronized completely especially at the end of log.
Consequence: The indentation has to be thread save.