def check_busy(func):
"""
Decorator to check for self.is_busy
Only one of the decorated functions may run simultaniously
"""
@wraps(func)
def decorator(self, *args, **kwargs):
if self.is_busy:
logging.critical("Already busy. Please wait.")
return None
self.is_busy = True
try:
func(self, *args, **kwargs)
except Exception as e:
logging.critical(e)
self.is_busy = False
return decorator
评论列表
文章目录