19 lines
438 B
Python
19 lines
438 B
Python
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
from functools import wraps
|
|
|
|
|
|
def with_defer(deferred_func):
|
|
def decorator(fn):
|
|
@wraps(fn)
|
|
def wrapper(*args, **kwargs):
|
|
try:
|
|
return fn(*args, **kwargs)
|
|
finally:
|
|
deferred_func()
|
|
|
|
return wrapper
|
|
|
|
return decorator
|