从paddle源码上学了这么一段
自己写了个demo
from contextlib import contextmanager
@contextmanager
def phase():
print("新增dev任务")
yield
print("退出dev任务")
with phase():
print("开始测试\n", end="")
从paddle源码上学了这么一段
自己写了个demo
from contextlib import contextmanager
@contextmanager
def phase():
print("新增dev任务")
yield
print("退出dev任务")
with phase():
print("开始测试\n", end="")