总线通信架构整改完成
This commit is contained in:
		@@ -1,14 +1,19 @@
 | 
			
		||||
from functools import wraps
 | 
			
		||||
from codes.common import db_operation
 | 
			
		||||
from inspect import getfile
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
def handle_exception(module, stop: bool = False):
 | 
			
		||||
 | 
			
		||||
def handle_exception(stop: bool = False):
 | 
			
		||||
    def exceptions(func):
 | 
			
		||||
        module = Path(getfile(func)).stem
 | 
			
		||||
        func_name = func.__name__
 | 
			
		||||
        @wraps(func)
 | 
			
		||||
        def wrapper(*args, **kwargs):
 | 
			
		||||
            try:
 | 
			
		||||
                return func(*args, **kwargs)
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                db_operation.db_write_logs(e, module, "exception")
 | 
			
		||||
                db_operation.db_write_logs(str(e), "@".join([func_name, module]), "exception")
 | 
			
		||||
                if stop:
 | 
			
		||||
                    raise e
 | 
			
		||||
        return wrapper
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user