def wrapped_function(*params, **kwargs): database_connection_handler = DatabaseConnectionHandler() kwargs["database_session"] = database_connection_handler.session try: return func(*params, **kwargs) except Exception as err: raise err finally: database_connection_handler.session.close() database_connection_handler.engine.dispose()
def wrapped_function(*params, **kwargs): database_connection_handler = DatabaseConnectionHandler() kwargs["database_session"] = database_connection_handler.session while True: try: return func(*params, **kwargs) except OperationalError: continue else: database_connection_handler.session.close()
def process_aplication(self): DatabaseConnectionHandler.initialize_db_connection_handler() configuration = self.parser.parse_args() self.action_handlers[configuration.ACTION].process_action(configuration)
def __init__(self, configuration): self.configuration = configuration DatabaseConnectionHandler.initialize_db_connection_handler()