forked from mtusi2026/mtusi2026lab7
Implement lab7 mTLS, scoped OpenBao secrets and worker compromise experiment
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
"""Keep resource leases until a blocking operation actually finishes on cancellation."""
|
||||
import asyncio
|
||||
|
||||
|
||||
async def complete_thread(function, *args):
|
||||
task = asyncio.create_task(asyncio.to_thread(function, *args))
|
||||
try:
|
||||
return await asyncio.shield(task)
|
||||
except asyncio.CancelledError:
|
||||
# asyncio cancellation cannot stop a Python thread. Do not close its file
|
||||
# or release its decoder/upload permit while it is still using them.
|
||||
try:
|
||||
await asyncio.shield(task)
|
||||
except Exception:
|
||||
pass
|
||||
raise
|
||||
Reference in New Issue
Block a user