Skip to content

[SU] Extendable test timeouts #759

@khodya

Description

@khodya

Extendable test timeouts

It is hard to predict what test timeout to set in Software Update tests -- it depends on the image size. Implement a feedback mechanism in tests that prompts a user whether the timeout should be extended and extends the timeout.

reschedule method

One of the possible implementations is reschedule method and asynchronous context managers.

Example:

import asyncio

async def my_task():
    try:
        # Start with a 5-second timeout
        async with asyncio.timeout(5) as delay:
            print("Starting long task...")
            await asyncio.sleep(3)
            
            # Something happened! We need more time.
            # Extend it by another 5 seconds from right now
            new_deadline = asyncio.get_running_loop().time() + 5
            delay.reschedule(new_deadline)
            print("Timeout extended!")
            
            await asyncio.sleep(4) 
    except TimeoutError:
        print("Task timed out anyway!")

asyncio.run(my_task())

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions