robotframework-debuglibrary icon indicating copy to clipboard operation
robotframework-debuglibrary copied to clipboard

Versions 2.4.0 and later crash when the test case is started inside VSCode using the RobotCode (d-biehl.robotcode) extension.

Open JasonFerrara opened this issue 1 year ago • 1 comments

With robotframework-debuglibrary 2.40 and later, when the Debug keyword is called in a test case started in VSCode using the RobotCode extension instead of getting the interactive debug prompt you get...

| FAIL | asyncio.run() cannot be called from a running event loop

Version 2.3.0 works as expected.

Attached is a sample VSCode project that show the problem. Open the project in VSCode, click "Reopen in Container". After the project reloads open the debugtest.robot file and click the run button next to the Check DebugLibrary test case. Instead of the interactive prompt you'll get...

 /workspaces/robotdebuglibrarybug #  /usr/bin/env /usr/bin/python /root/.vscode-server/extensions/d-biehl.robotcode-0.69.0/bundled/tool/robotcode --default-path . debug --
no-debug -- --parse-include debugtest.robot --name Robotdebuglibrarybug --suite Robotdebuglibrarybug.Debugtest --by-longname Robotdebuglibrarybug.Debugtest.Check\ DebugLi
brary 
==============================================================================
Robotdebuglibrarybug                                                          
==============================================================================
Robotdebuglibrarybug.Debugtest                                                
==============================================================================
Check DebugLibrary                                                    
>>>>> Enter interactive shell
Only accepted plain text format keyword separated with two or more spaces.
Type "help" for more information.
Check DebugLibrary                                                    | FAIL |
asyncio.run() cannot be called from a running event loop
------------------------------------------------------------------------------
Robotdebuglibrarybug.Debugtest                                        | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Robotdebuglibrarybug                                                  | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /workspaces/robotdebuglibrarybug/results/output.xml
Log:     /workspaces/robotdebuglibrarybug/results/log.html
Report:  /workspaces/robotdebuglibrarybug/results/report.html
sys:1: RuntimeWarning: coroutine 'Application.run_async' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
/workspaces/robotdebuglibrarybug # 

If you edit the Dockerfile to install robotframework-debuglibrary 2.3.0 instead of 2.5.0 when you run the test case you'll get...

/workspaces/robotdebuglibrarybug #  /usr/bin/env /usr/bin/python /root/.vscode-server/extensions/d-biehl.robotcode-0.69.0/
bundled/tool/robotcode --default-path . debug --no-debug -- --parse-include debugtest.robot --name Robotdebuglibrarybug --
suite Robotdebuglibrarybug.Debugtest --by-longname Robotdebuglibrarybug.Debugtest.Check\ DebugLibrary 
==============================================================================
Robotdebuglibrarybug                                                          
==============================================================================
Robotdebuglibrarybug.Debugtest                                                
==============================================================================
Check DebugLibrary                                                    
>>>>> Enter interactive shell
Only accepted plain text format keyword separated with two or more spaces.
Type "help" for more information.
>    

as expected. robotdebuglibrarybug.tar.gz

JasonFerrara avatar Jan 24 '24 14:01 JasonFerrara

@JasonFerrara The only significant change from v2.3.0 to v2.4.0 is that prompt-toolkit was upgraded from v2 to v3.

Also, I've noticed that both prompt-toolkit and RobotCode are using eventloop, which may be the cause of the issue.

Maybe I can add a switch to let prompt-toolkit choose not to use eventloop, but I'm not sure if prompt-toolkit supports this. Any more suggestions would also be welcome.

You can use v2.3.0 for now until this issue is resolved.

xyb avatar Jan 26 '24 15:01 xyb