def test_alwaysTransaction(): """hub.getConnection always returns a Transaction""" hub = database.AutoConnectHub("sqlite:///:memory:") try: assert isinstance(hub.getConnection(), dbconnection.Transaction) database.end_all() assert not isinstance(hub.threadingLocal.connection, dbconnection.Transaction) finally: database.hub_registry.clear()
def __call__(self, *args, **kw): applogger.debug("schedSafe: begin") hub.threadingLocal = threading_local() hub.begin() try: ret = self.f(*args, **kw) applogger.debug("schedSafe: %s returned %s" % (self.f.__name__, ret)) finally: commit_all() end_all() applogger.debug("schedSafe: done")
def test_alwaysTransaction(): "hub.getConnection always returns a Transaction" assert isinstance(hub.getConnection(), dbconnection.Transaction) database.end_all() assert not isinstance(hub.threadingLocal.connection, dbconnection.Transaction)