2021-07-25 22:52:13 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import anyio
|
2021-07-26 00:29:20 -06:00
|
|
|
from functools import wraps
|
2021-07-25 22:52:13 -06:00
|
|
|
|
|
|
|
def shield(f):
|
2021-07-26 00:29:20 -06:00
|
|
|
@wraps(f)
|
2021-07-25 22:52:13 -06:00
|
|
|
async def shielded(*args, **kwargs):
|
2021-07-26 00:29:20 -06:00
|
|
|
with anyio.CancelScope(shield=True):
|
2021-07-25 22:52:13 -06:00
|
|
|
return await f(*args, **kwargs)
|
|
|
|
return shielded
|