usim
usim copied to clipboard
Inconsistent postponement on exceptions
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.