usim icon indicating copy to clipboard operation
usim copied to clipboard

Inconsistent postponement on exceptions

Open maxfischer2781 opened this issue 4 years ago • 0 comments

Description of the bug The asynchronous Resource.claim operation does not postpone when claiming fails. This violates usim's guarantee to always postpone on an asynchronous operation.

This issue may apply to other operations as well.

How To Reproduce Performing an impossible claim does not allow other activities to run.

from usim import instant, run, Resources, ResourcesUnavailable

async def fail_postponed():
    res = Resources(capacity=1)
    try:
        async with res.claim(capacity=2):
            pass
    except ResourcesUnavailable:
        print("Postponed?")

async def postponed():
    print("Before postponement...")
    await instant
    print("After postponement...")

run(fail_postponed(), postponed())

Expected behavior Any asynchronous operation should postpone at least once before raising a non-failure Exception.

maxfischer2781 avatar Oct 25 '19 19:10 maxfischer2781