def get(self): tid = thread.get_ident() txn = self._txns.get(tid) if txn is None: synchs = self._synchs.get(tid) if synchs is None: synchs = self._synchs[tid] = WeakSet() txn = self._txns[tid] = Transaction(synchs, self) return txn
def get(self): tid = thread.get_ident() txn = self._txns.get(tid) if txn is None: synchs = self._synchs.get(tid) if synchs is None: from ZODB.utils import WeakSet synchs = self._synchs[tid] = WeakSet() if self._global_syncs: [synchs.add(gs) for gs in self._global_syncs] txn = self._txns[tid] = Transaction(synchs, self) return txn
def begin(self): tid = thread.get_ident() txn = self._txns.get(tid) if txn is not None: txn.abort() synchs = self._synchs.get(tid) if synchs is None: synchs = self._synchs[tid] = WeakSet() txn = self._txns[tid] = Transaction(synchs, self) _new_transaction(txn, synchs) return txn
def begin(self): tid = thread.get_ident() txn = self._txns.get(tid) if txn is not None: txn.abort() synchs = self._synchs.get(tid) if synchs is None: from ZODB.utils import WeakSet synchs = self._synchs[tid] = WeakSet() if self._global_syncs: [synchs.add(gs) for gs in self._global_syncs] txn = self._txns[tid] = Transaction(synchs, self) _new_transaction(txn, synchs) return txn
def __init__(self, pool_size): # The largest # of connections we expect to see alive simultaneously. self.pool_size = pool_size # A weak set of all connections we've seen. A connection vanishes # from this set if pop() hands it out, it's not reregistered via # repush(), and it becomes unreachable. self.all = WeakSet() # A stack of connections available to hand out. This is a subset # of self.all. push() and repush() add to this, and may remove # the oldest available connections if the pool is too large. # pop() pops this stack. There are never more than pool_size entries # in this stack. # In Python 2.4, a collections.deque would make more sense than # a list (we push only "on the right", but may pop from both ends). self.available = []
def __init__(self, synchronizers=None, manager=None): self.status = Status.ACTIVE # List of resource managers, e.g. MultiObjectResourceAdapters. self._resources = [] # Weak set of synchronizer objects to call. if synchronizers is None: from ZODB.utils import WeakSet synchronizers = WeakSet() self._synchronizers = synchronizers self._manager = manager # _adapters: Connection/_p_jar -> MultiObjectResourceAdapter[Sub] self._adapters = {} self._voted = {} # id(Connection) -> boolean, True if voted # _voted and other dictionaries use the id() of the resource # manager as a key, because we can't guess whether the actual # resource managers will be safe to use as dict keys. # The user, description, and _extension attributes are accessed # directly by storages, leading underscore notwithstanding. self._extension = {} self.log = logging.getLogger("txn.%d" % thread.get_ident()) self.log.debug("new transaction") # If a commit fails, the traceback is saved in _failure_traceback. # If another attempt is made to commit, TransactionFailedError is # raised, incorporating this traceback. self._failure_traceback = None # List of (hook, args, kws) tuples added by addBeforeCommitHook(). self._before_commit = [] # List of (hook, args, kws) tuples added by addAfterCommitHook(). self._after_commit = []
def __init__(self): self._txn = None self._synchs = WeakSet()
def registerSynch(self, synch): tid = thread.get_ident() ws = self._synchs.get(tid) if ws is None: ws = self._synchs[tid] = WeakSet() ws.add(synch)