Exemple #1
0
 def _safe_execute(self, *args, **kwds):
     """Execute an sqlalchemy query, raise BackendError on failure."""
     try:
         return self._engine.execute(*args, **kwds)
     except (OperationalError, TimeoutError), exc:
         err = traceback.format_exc()
         logger.error(err)
         raise BackendError(str(exc))
Exemple #2
0
 def _safe_execute(self, *args, **kwds):
     """Execute an sqlalchemy query, raise BackendError on failure."""
     try:
         return self._engine.execute(*args, **kwds)
     except (OperationalError, TimeoutError), exc:
         err = traceback.format_exc()
         logger.error(err)
         raise BackendError(str(exc))
Exemple #3
0
    def _safe_execute(self, *args, **kwds):
        """Execute an sqlalchemy query, raise BackendError on failure."""
        if hasattr(args[0], 'bind'):
            engine = args[0].bind
        else:
            engine = None

        if engine is None:
            engine = kwds.get('engine')
            if engine is None:
                engine = self._get_engine(kwds.get('service'))
            else:
                del kwds['engine']

        try:
            return engine.execute(*args, **kwds)
        except (OperationalError, TimeoutError), exc:
            err = traceback.format_exc()
            logger.error(err)
            raise BackendError(str(exc))
    def _safe_execute(self, *args, **kwds):
        """Execute an sqlalchemy query, raise BackendError on failure."""
        if hasattr(args[0], 'bind'):
            engine = args[0].bind
        else:
            engine = None

        if engine is None:
            engine = kwds.pop('engine', None)
            if engine is None:
                engine = self._get_engine(kwds.get('service'))

        if 'service' in kwds:
            kwds['service'] = self._get_service_id(kwds['service'])

        try:
            return engine.execute(*args, **kwds)
        except (OperationalError, TimeoutError), exc:
            err = traceback.format_exc()
            logger.error(err)
            raise BackendError(str(exc))