threading: local scope of thread overwritten in case of reentrance of keyword
*** Settings **
Library Collections
Library String
*** Keywords ***
#
# Threading payload base keywords
#
################################################################################
threading_keyword_multiple_time_called.keyword
[Arguments] ${msg}="" ${waittime}=5
Log Entering Thread ${msg} console=True
sleep ${waittime}
Log Closing Thread ${msg} console=True
*** Test Cases ***
Threading Keyword Multiple Time Called
# ${payload1} = Evaluate {'CLIENT':{'NAME':'NAME','ID':1},'SERVER': {'ID':2,'IP':'172.17.0.4','PORT':'12345'},'SERVICE':{'ID':'ECHOSERVICE'}}
#
THREAD TEST_THREAD1 False
threading_keyword_multiple_time_called.keyword msg="thrd1" waittime=5
END
THREAD TEST_THREAD2 False
threading_keyword_multiple_time_called.keyword msg="thrd2" waittime=1
END
THREAD TEST_THREAD3 False
threading_keyword_multiple_time_called.keyword msg="thrd3" waittime=1
END
THREAD TEST_THREAD4 False
threading_keyword_multiple_time_called.keyword msg="thrd4" waittime=1
END
Sleep 10
Results in unexpected:
should be "Entering Thread 1,2,3,4" and accordingly closing. Order is arbitrary ,but repetition of same string argument is a bug.
$ cd C:\\RobotTest\\testcases ; /usr/bin/env C:\\Users\\pol2hi\\AppData\\Local\\Temp\\rf-ls-run\\run_env_00_rpwvdqgq.bat -u c:\\Program\ Files\\RobotFramework\\robotvscode\\data\\extensions\\robocorp.robotframework-lsp-1.11.0\\src\\robotframework_debug_adapter\\run_robot__main__.py --port 62032 --no-debug -T -d C:\\RobotTest\\testcases\\..\\logfiles -b debug\\hanging_thread.log -l htmllog\\hanging_thread_log.html -o xmloutput\\hanging_thread_output.xml -r htmlreport\\hanging_thread_report.html c:\\RobotTest\\testcases\\hanging_thread.robot
==============================================================================
Hanging Thread
==============================================================================
Threading Keyword Multiple Time Called Entering Thread "thrd1"
Entering Thread "thrd4"
Entering Thread "thrd3"
Entering Thread "thrd3"
Closing Thread "thrd3"
Closing Thread "thrd3"
Closing Thread "thrd3"
Closing Thread "thrd3"
RFStream Warning: keyword - BuiltIn.Sleep did not have a corresponding pop.
RFStream Warning: keyword - .threading_keyword_multiple_time_called.keyword did not have a corresponding pop.
RFStream Warning: keyword - BuiltIn.Sleep did not have a corresponding pop.
RFStream Warning: unable to pop keyword - BuiltIn.Sleep because it does not match the current top: suite - s1
RFStream Warning: unable to pop keyword - BuiltIn.Sleep because it does not match the current top: suite - s1
Threading Keyword Multiple Time Called | PASS |
------------------------------------------------------------------------------
Hanging Thread | PASS |
1 test, 1 passed, 0 failed, 0 unknown
==============================================================================
Debug: C:\RobotTest\logfiles\debug\hanging_thread-20231110-141935.log
Output: C:\RobotTest\logfiles\xmloutput\hanging_thread_output-20231110-141935.xml
Log: C:\RobotTest\logfiles\htmllog\hanging_thread_log-20231110-141935.html
Report: C:\RobotTest\logfiles\htmlreport\hanging_thread_report-20231110-141935.html
threading: local scope of thread overwritten in case of reentrance of keyword
Results in unexpected: should be "Entering Thread 1,2,3,4" and accordingly closing. Order is arbitrary ,but repetition of same string argument is a bug.
THREAD builtin deactivated results in correct: