Closed jaltendorfer closed 6 months ago
Cannot reproduce this.
Can you perhaps add a short example code?
Here is an example.
Test.py:
import asyncio
from robot.api.deco import keyword, library
@library(scope="SUITE", version="1.0")
class Test:
@keyword("Async Sleep")
async def async_sleep(self, sleep_time: int):
await asyncio.sleep(sleep_time)
test.robot:
*** Settings ***
Library Test.py
*** Test Cases ***
Test
Log start
Async Sleep 5
Log end
Message in terminal output:
RuntimeWarning: coroutine 'Test.async_sleep' was never awaited step.run(self._context, self._run, self._templated) RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Hello, Similar problem for me. Trying to run keywords, which are using pyshark library inside, but got an error "RuntimeError: This event loop is already running"
@keyword("Acquire packet from remote interface")
def sniff_for_packet(hostname, remote_if: str, packet_count: int, bpf_filter: str = None):
capture = RemoteCapture(hostname, remote_if, bpf_filter=bpf_filter, debug=True)
capture.sniff(packet_count=packet_count)
logger.info(f"Capture {capture}")
Remote Capture test
Acquire packet from remote interface ${rpcapd_servise} eno1 5
Error message in a terminal output:
sys:1: RuntimeWarning: coroutine 'Capture.packets_from_tshark' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback
In a robot log:
ok, after some investigation I find out that the implementation of calling async keywords in RF does not work if there is already a running event loop. see here I think that should work too or at least a correct error message should appear.
on the other hand, I'm about to rework some async code, because async has some performance and syncronisation problems.
It's about time I do that for the debugger ;-) will have a closer look at it.
@pkomarov I don't know the pyshark library, but your keyword implementation has no async
maybe this is an error in the pyshark library. Or does this happen if you add asycn
to you keyword implementation?
@pkomarov I don't know the pyshark library, but your keyword implementation has no
async
maybe this is an error in the pyshark library. Or does this happen if you addasycn
to you keyword implementation?
@d-biehl If I run from console, test works fine, from "Robot Framework Language Server" plugin also works fine. If I add async to a keyword - nothing is happend at all:
Looking forward you fix this issue, would like to migrate from Robot Framework Language Server
Describe the bug In RF 6.1 async keyword support was added, but when running tests with the robotcode extention in VSCode, it does not work. The error is: "RuntimeWarning: coroutine 'library.keyword_name' was never awaited"
With the robotframework language server plugin it works normally.
To Reproduce Steps to reproduce the behavior:
Expected behavior Async keywords should be executed normally (like robotframework does it when using the robot command).
Desktop (please complete the following information):