Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Async keywords are not stopped when execution is stopped gracefully #4808

Closed
@jaltendorfer

Description

@jaltendorfer

Stop a test execution during an async keyword with SIGINT or CTRL+C. Now the teardown with async keywords is executed, but the test keyword still runs and is not stopped.

Example:

Test python library:

import asyncio
from robot.api.deco import library, keyword
from robot.api import logger


@library
class TestLibrary:

    @keyword(name="Async Sleep")
    async def async_sleep(self, time: int, log_message: str):
        logger.info(f"{log_message} start", also_console=True)
        await asyncio.sleep(time)
        logger.info(f"{log_message} end", also_console=True)

Test robot suite:

*** Settings ***
Library    TestLibrary.py


*** Test Cases ***
Test
    TestLibrary.Async Sleep    ${5}    Sleep Test
    [Teardown]    TestLibrary.Async Sleep    ${10}    Sleep Teardown

Result:

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions