def cross_validation_lock(self):
"""
A contextmanager for running a block with our cross validation lock set
to True.
At the end of the block, the lock's value is restored to its value
prior to entering the block.
"""
if self._cross_validation_lock:
yield
return
else:
try:
self._cross_validation_lock = True
yield
finally:
self._cross_validation_lock = False
评论列表
文章目录