custom-components / pyscript

Pyscript adds rich Python scripting to HASS
Apache License 2.0
873 stars 46 forks source link

"async with" statement fails without target variable assignment #581

Open dmamelin opened 8 months ago

dmamelin commented 8 months ago

This code causes an error: RuntimeError: Lock is not acquired.

lock = asyncio.Lock()
async with lock:
    pass

Workaround:

lock = asyncio.Lock()
async with lock as lock_test:
    pass