rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
home = args[0] if not os.path.isabs(home): home = os.path.abspath(home) | instance_home = args[0] if not os.path.isabs(instance_home): instance_home = os.path.abspath(instance_home) for entry in sys.path: if os.path.exists(os.path.join(entry, 'Zope')): zope_home = entry break else: print "Can't find the Zope home (not in sys.path)" sys.exit(2) | def run(self): try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) except getopt.error, msg: print msg sys.exit(2) program = os.path.basename(sys.argv[0]) if opts: # There's only the help options, so just dump some help: msg = __doc__ % {"program": program} print msg sys.exit() if len(args) not in [1, 2]: prin... |
params = self.get_params(home, port) self.create(home, params) def get_params(self, home, port): | params = self.get_params(zope_home, instance_home, port) self.create(instance_home, params) def get_params(self, zope_home, instance_home, port): | def run(self): try: opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) except getopt.error, msg: print msg sys.exit(2) program = os.path.basename(sys.argv[0]) if opts: # There's only the help options, so just dump some help: msg = __doc__ % {"program": program} print msg sys.exit() if len(args) not in [1, 2]: prin... |
"home": home, | "zope_home": zope_home, "instance_home": instance_home, | def get_params(self, home, port): return { "package": "zeo", "PACKAGE": "ZEO", "home": home, "port": port, "python": sys.executable, "server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"), } |
"server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"), | def get_params(self, home, port): return { "package": "zeo", "PACKAGE": "ZEO", "home": home, "port": port, "python": sys.executable, "server": which("runzeo.py"), "zdrun": which("zdrun.py"), "zdctl": which("zdctl.py"), } | |
poll_fun = asyncore.poll | poll_fun = poll | def loop(timeout=30.0, use_poll=0, map=None): """Invoke asyncore mainloop This function functions like the regular asyncore.loop() function except that it also triggers ThreadedAsync callback functions before starting the loop. """ if use_poll: if hasattr(select, 'poll'): poll_fun = asyncore.poll3 else: poll_fun = asy... |
name = str(self.storage) | name = str(storage) | def slog(storage, msg, level=zLOG.INFO, error=None, pid=os.getpid()): name = getattr(storage, '__name__', None) if name is None: name = str(self.storage) zLOG.LOG("ZEO Server:%s:%s" % (pid, name), level, msg, error=error) |
cserial, cdataptr, cver, cdata = self._undoDataInfo( | cserial, cdataptr, cdata, cver = self._undoDataInfo( | def _transactionalUndoRecord(self, oid, pos, serial, pre, version): """Get the indo information for a data record |
class FileStorage: _packt=0 _transaction=None _serial=z64 def __init__(self, file_name, create=0, read_only=0, stop=None): | class FileStorage(BaseStorage.BaseStorage): _packt=z64 def __init__(self, file_name, create=0, read_only=0, stop=None, base=None): | def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message |
self.__name__=file_name | BaseStorage.BaseStorage.__init__(self, file_name) | def __init__(self, file_name, create=0, read_only=0, stop=None): |
self._index=index self._vindex=vindex self._tindex=tindex self._tvindex=tvindex self._indexpos=index.get self._vindexpos=vindex.get self._tappend=tindex.append l=bpthread.allocate_lock() self._a=l.acquire self._r=l.release l=bpthread.allocate_lock() self._ca=l.acquire self._cr=l.release | self._initIndex(index, vindex, tindex, tvindex) self._base=base | def __init__(self, file_name, create=0, read_only=0, stop=None): |
return self.commitVersion(src, '', transaction, abort=1) def close(self): self._file.close() def commitVersion(self, src, dest, transaction, abort=None): if dest and abort: raise 'VersionCommitError', ( 'Internal error, can\'t abort to a version') | def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers. | |
self._a() | self._lock_acquire() | def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers. |
srcpos=self._vindex.get(src, 0) | srcpos=self._vindex_get(src, 0) | def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers. |
middle=p64(self._pos)+'\0'*10 here=tfile.tell()+self._pos+self._thl oids=[] appoids=oids.append while srcpos: seek(srcpos) h=read(58) oid=h[:8] if index[oid]==srcpos: tappend((oid,here)) appoids(oid) write(h[:16] + spos + middle + h[-16:-8]) here=here+50 spos=h[-8:] srcpos=u64(spos) self._tvindex[src]=0 return oi... | def abortVersion(self, src, transaction): # We are going to abort by simply storing back pointers. | |
sd=p64(self._vindex.get(dest, 0)) | sd=p64(self._vindex_get(dest, 0)) | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... |
current_oids={} current=current_oids.has_key t=None tstatus=' ' | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... | |
write(h[-16:-8]+sd+dest) | write(pnv+sd+dest) | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... |
write(spos) | write(abort and pnv or spos) | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... |
tvindex[src]=0 | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... | |
finally: self._r() def getName(self): return self.__name__ | finally: self._lock_release() | def commitVersion(self, src, dest, transaction): # We are going to commit by simply storing back pointers. if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) self._a() try: file=self._file read=file.read seek=file.seek tfile=self._tfile write=tfile.write tappend=sel... |
def history(self, oid, version, length=1): pass | def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version='' if plen != z64: return read(u64(plen)), version return _loadBa... | def getSize(self): return self._pos |
self._a() | self._lock_acquire() | def load(self, oid, version, _stuff=None): self._a() try: pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) # Read location of non-version data if (not version or len(... |
pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) if (not version or len(version) != vlen or (read(8) and version != read(vlen)) ): return _loadBack(file, oid, pnv) ... | try: return self._load(oid, version, self._index, self._file) except: if self._base is not None: return self._base.load(oid, version) raise finally: self._lock_release() | def load(self, oid, version, _stuff=None): self._a() try: pos=self._index[oid] file=self._file file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if doid != oid: raise CorruptedDataError, h if vlen: pnv=read(8) # Read location of non-version data if (not version or len(... |
self._a() | self._lock_acquire() | def modifiedInVersion(self, oid): self._a() try: pos=self._index[oid] file=self._file seek=file.seek seek(pos) doid,serial,prev,tloc,vlen = unpack(">8s8s8s8sH", file.read(34)) if doid != oid: raise CorruptedDataError, h if vlen: seek(24,1) # skip plen, pnv, and pv return file.read(vlen) return '' finally: self._r() |
finally: self._r() def new_oid(self, last=None): if last is None: self._a() try: last=self._oid d=ord(last[-1]) if d < 255: last=last[:-1]+chr(d+1) else: last=self.new_oid(last[:-1]) self._oid=last return last finally: self._r() else: d=ord(last[-1]) if d < 255: return last[:-1]+chr(d+1)+'\0'*(8-len(last)) else:... | finally: self._lock_release() | def modifiedInVersion(self, oid): self._a() try: pos=self._index[oid] file=self._file seek=file.seek seek(pos) doid,serial,prev,tloc,vlen = unpack(">8s8s8s8sH", file.read(34)) if doid != oid: raise CorruptedDataError, h if vlen: seek(24,1) # skip plen, pnv, and pv return file.read(vlen) return '' finally: self._r() |
self._a() | self._lock_acquire() | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
old=self._indexpos(oid, 0) | old=self._index_get(oid, 0) | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
pv=tvindex.get(version, 0) or self._vindexpos(version, 0) | pv=tvindex.get(version, 0) or self._vindex_get(version, 0) | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
finally: self._r() def registerDB(self, db, limit): pass def supportsUndo(self): return 0 | finally: self._lock_release() def supportsUndo(self): return 1 | def store(self, oid, serial, data, version, transaction): if transaction is not self._transaction: raise POSException.StorageTransactionError(self, transaction) |
def tpc_abort(self, transaction): self._a() | def _clear_temp(self): del self._tindex[:] self._tvindex.clear() self._tfile.seek(0) def _begin(self, tid, u, d, e): self._thl=23+len(u)+len(d)+len(e) def _finish(self, tid, u, d, e): file=self._file write=file.write tfile=self._tfile dlen=tfile.tell() tfile.seek(0) id=self._serial user, desc, ext = self._ude tlen=s... | def supportsVersions(self): return 1 |
if transaction is not self._transaction: return del self._tindex[:] self._transaction=None self._cr() finally: self._r() def tpc_begin(self, transaction): self._a() try: if self._transaction is transaction: return self._r() self._ca() self._a() self._transaction=transaction del self._tindex[:] self._tvindex.clear() se... | transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) packt=self._packt if packt is None or packt > tid: raise POSException.UndoError, ( 'Undo is currently disabled for database maintenance.<p>') | def tpc_abort(self, transaction): self._a() try: if transaction is not self._transaction: return del self._tindex[:] self._transaction=None self._cr() finally: self._r() |
indexpos=self._indexpos | index_get=self._index_get | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... |
transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... | |
t=[] tappend=t.append | t={} | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... |
if indexpos(oid,0) != pos: | if index_get(oid,0) != pos: | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... |
tappend((oid,prev)) | t[oid]=prev | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... |
for oid, pos in t: index[oid]=pos finally: self._r() | for oid, pos in t.items(): index[oid]=pos return t.keys() finally: self._lock_release() | def undo(self, transaction_id): self._a() try: file=self._file seek=file.seek read=file.read indexpos=self._indexpos unpack=struct.unpack transaction_id=base64.decodestring(transaction_id+'==\n') tid, tpos = transaction_id[:8], u64(transaction_id[8:]) seek(tpos) h=read(23) if len(h) != 23 or h[:8] != tid: raise UndoErr... |
self._a() | self._lock_acquire() | def undoLog(self, first, last, filter=None): self._a() try: pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip encode=base64.encodestring r=[] append=r.append i=0 while i < last and pos > 39: seek(pos-8) pos=pos-u64(read(8))-8 if i < first: continu... |
finally: self._r() | finally: self._lock_release() | def undoLog(self, first, last, filter=None): self._a() try: pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unpack strip=string.strip encode=base64.encodestring r=[] append=r.append i=0 while i < last and pos > 39: seek(pos-8) pos=pos-u64(read(8))-8 if i < first: continu... |
return not self._vindex.get(version, 0) | self._lock_acquire() try: index=self._index file=self._file seek=file.seek read=file.read srcpos=self._vindex_get(version, 0) t=tstatus=None while srcpos: seek(srcpos) oid=read(8) if index[oid]==srcpos: return 0 h=read(50) tloc=h[16:24] if t != tloc: t=tloc seek(u64(t)+16) tstatus=read(1) if tstatus != 'u': return 1... | def versionEmpty(self, version): return not self._vindex.get(version, 0) |
if max: return self._vindex.keys()[:max] return self._vindex.keys() | r=[] a=r.append for version in self._vindex.keys()[:max]: if self.versionEmpty(version): continue a(version) if max and len(r) >= max: return r return r def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than... | def versions(self, max=None): if max: return self._vindex.keys()[:max] return self._vindex.keys() |
indexpos=index.get | index_get=index.get | def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFor... |
pos=tpos+tl seek(pos) | seek(tend) | def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFor... |
pos=pos+8 | pos=tend+8 | def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFor... |
if indexpos(oid,0) != prev: | if index_get(oid,0) != prev: | def read_index(file, name, index, vindex, tindex, stop='\377'*8): indexpos=index.get vndexpos=vindex.get tappend=tindex.append read=file.read seek=file.seek seek(0,2) file_size=file.tell() seek(0) if file_size: if file_size < 4: raise FileStorageFormatError, file.name if read(4) != packed_version: raise FileStorageFor... |
pos = 4 | pos = 4L | def recover(inp, outp, verbose=0, partial=0, force=0, pack=0): print "Recovering", inp, "into", outp if os.path.exists(outp) and not force: die("%s exists" % outp) f = open(inp, "rb") if f.read(4) != ZODB.FileStorage.packed_version: die("input is not a file storage") f.seek(0,2) file_size = f.tell() ofs = ZODB.File... |
"src/ZEO/runzeo.py", "src/ZEO/zeopasswd.py", "src/ZEO/mkzeoinst.py", "src/ZEO/zeoctl.py", | def BTreeExtension(flavor): key = flavor[0] value = flavor[1] name = "BTrees._%sBTree" % flavor sources = ["src/BTrees/_%sBTree.c" % flavor] kwargs = {"include_dirs": include} if flavor != "fs": kwargs["depends"] = (base_btrees_depends + [KEY_H % _flavors[key], VALUE_H % _flavors[value]]) if key != "O": kwargs["define_... | |
self.strategy.tpc_abort() | strategy = self.strategy strategy.tpc_abort() | def tpc_abort(self, id): if not self._check_tid(id): return self.strategy.tpc_abort() self._transaction = None self.strategy = None self._handle_waiting() |
self._handle_waiting() | if isinstance(strategy, ImmediateCommitStrategy): self._handle_waiting() | def tpc_abort(self, id): if not self._check_tid(id): return self.strategy.tpc_abort() self._transaction = None self.strategy = None self._handle_waiting() |
'opened': c._opened and ctime(c._opened), | 'opened': o and ("%s (%.2fs)" % (ctime(o), t-o)), | def connectionDebugInfo(self): r=[] pools,pooll=self._pools for version, (pool, allocated, lock) in pools.items(): for c in allocated: r.append({ 'opened': c._opened and ctime(c._opened), 'info': c._debug_info, 'version': version, }) return r |
class ISized(ICollection): def __len__(): """Return the number of items in the set""" class IReadSequence(Interface.Base): def __getitem__(index): """Return an item for a given index.""" | class IReadSequence(Interface.Standard.Sequence): | def __nonzero__(): """Check if the collection is non-empty. |
class IKeySequence(IKeyed, ISized): | class IKeySequence(IKeyed, Interface.Standard.Sized): | def update(seq): """Add the items from the given sequence to the set""" |
class IDictionaryIsh(IKeyed, ISized): def __getitem__(key): """Get the value for the given key Raise a key error if the key if not in the collection. """ def get(key, default=None): """Get the value for the given key Raise a key error if the key if not in the collection and no default is specified. Return the defa... | class IDictionaryIsh(IKeyed, Interface.Standard.MinimalDictionary): | def __getitem__(index): """Return the key in the given index position |
class IMerge(Interfaces.Base): | class IMerge(Interface.Base): | def insert(key, value): """Insert a key and value into the collection. |
Interface.assertTypeImplements(OOBTree.OOSet, ISet) Interface.assertTypeImplements(OOBTree.OOTreeSet, ITreeSet) Interface.assertTypeImplements(OOBTree.OOBucket, IDictionaryIsh) Interface.assertTypeImplements(OOBTree.OOBTree, IBTree) | OOBTree.OOSet.__implements__=ISet OOBTree.OOTreeSet.__implements__=ITreeSet OOBTree.OOBucket.__implements__=IDictionaryIsh OOBTree.OOBTree.__implements__=IBTree | def weightedIntersection(c1, c2, weight1=1, weight2=1): """Compute the weighted intersection of c1 and c2. |
class FileStorageError: pass class FileStorageFormatError(FileStorageError, POSException.StorageError): | class FileStorageError(POSException.StorageError): pass class FileStorageFormatError(FileStorageError): | def panic(message, *data): message=message%data LOG('ZODB FS',PANIC,"%s ERROR: %s\n" % (packed_version, message)) raise CorruptedTransactionError, message |
file.seek(16,1) | nv = read(8) != z64 file.seek(8,1) | def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version='' |
if plen != z64: return read(u64(plen)), version return _loadBack(file, oid, read(8))[0], version | nv=0 if plen != z64: return read(u64(plen)), version, nv return _loadBack(file, oid, read(8))[0], version, nv | def _loada(self, oid, _index, file): "Read any version and return the version" pos=_index[oid] file.seek(pos) read=file.read h=read(42) doid,serial,prev,tloc,vlen,plen = unpack(">8s8s8s8sH8s", h) if vlen: file.seek(16,1) version=read(vlen) else: version='' |
p, v = _loada(oid, index, file) | p, v, nv = _loada(oid, index, file) | def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, sinc... |
if v: | if nv: | def pack(self, t, referencesf): """Copy data from the current database file to a packed file Non-current records from transactions with time-stamp strings less than packtss are ommitted. As are all undone records. Also, data back pointers that point before packtss are resolved and the associated data are copied, sinc... |
def checkMultiStorageTransaction(self): | def NOcheckMultiStorageTransaction(self): | def checkMultiStorageTransaction(self): # Configuration parameters (larger values mean more likely deadlocks) N = 2 # These don't *have* to be all the same, but it's convenient this way self.nservers = N self.nthreads = N self.ntrans = N self.nobj = N |
if verbose: | if verbose or code in (0x00, 0x70): | def main(): # Parse options verbose = 0 dostats = 1 try: opts, args = getopt.getopt(sys.argv[1:], "vS") except getopt.error, msg: usage(msg) return 2 for o, a in opts: if o == "-v": verbose = 1 if o == "-S": dostats = 0 verbose = 1 if len(args) != 1: usage("exactly one file argument required") return 2 filename = args[... |
if verbose: print | print | def main(): # Parse options verbose = 0 dostats = 1 try: opts, args = getopt.getopt(sys.argv[1:], "vS") except getopt.error, msg: usage(msg) return 2 for o, a in opts: if o == "-v": verbose = 1 if o == "-S": dostats = 0 verbose = 1 if len(args) != 1: usage("exactly one file argument required") return 2 filename = args[... |
h, v = unpack(">II", s) | h, v = struct.unpack(">II", s) | def U64(s): h, v = unpack(">II", s) return (long(h) << 32) + v |
s.connect(('', 42000)) | s.connect(('localhost', 42000)) | def get_monitor_output(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('', 42000)) L = [] while 1: buf = s.recv(8192) if buf: L.append(buf) else: break s.close() return "".join(L) |
"""Insert a key and value into the colelction. | """Insert a key and value into the collection. | def insert(key, value): """Insert a key and value into the colelction. |
zLOG.LOG('ZEO Server', zLOG.INFO, 'Serving %s:\t%s' % kv) | LOG('ZEO Server', INFO, 'Serving %s:\t%s' % kv) | def handler(signum, frame, storages=storages, die=signal.SIGTERM): for storage in storages.values(): try: storage.close() finally: pass if signum==dir: sys.exit(0) else: sys.exit(1) |
auth_filename=self.options.auth_database, | auth_database=self.options.auth_database, | def create_server(self): from ZEO.StorageServer import StorageServer self.server = StorageServer( self.options.address, self.storages, read_only=self.options.read_only, invalidation_queue_size=self.options.invalidation_queue_size, transaction_timeout=self.options.transaction_timeout, monitor_address=self.options.monito... |
def testReadConflictIgnored(self): | def checkReadConflictIgnored(self): | def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() |
root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() real_data["a"] = PersistentDict({"indexed_value": 0}) real_data["b"] = PersistentDict({"indexed_value": 1}) index[1] = PersistentDict({"b": 1}) index[0] = PersistentDict({"a": 1}) | root["real_data"] = real_data = PersistentMapping() root["index"] = index = PersistentMapping() real_data["a"] = PersistentMapping({"indexed_value": 0}) real_data["b"] = PersistentMapping({"indexed_value": 1}) index[1] = PersistentMapping({"b": 1}) index[0] = PersistentMapping({"a": 1}) | def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() |
cn2.getTransaction().commit() | get_transaction().commit() | def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() |
self.assertRaises(ConflictError, get_transaction().commit) | self.assertRaises(ConflictError, cn2.getTransaction().commit) | def testReadConflictIgnored(self): # Test that an application that catches a read conflict and # continues can not commit the transaction later. root = self._db.open().root() root["real_data"] = real_data = PersistentDict() root["index"] = index = PersistentDict() |
self.sub1._p_jar = SubTransactionJar(errors='tpc_finish') self.nosub1.modify() self.sub1.modify(nojar=1) | for sub in self.sub1, self.sub2: sub._p_jar = SubTransactionJar(errors='tpc_finish') sub.modify(nojar=1) self.nosub1.modify() | def testExceptionInTpcFinish(self): |
self.sub1._p_jar = SubTransactionJar(errors='tpc_finish') self.nosub1.modify() self.sub1.modify(nojar=1) | for sub in self.sub1, self.sub2: sub._p_jar = SubTransactionJar(errors='tpc_finish') sub.modify(nojar=1) self.nosub1.modify() | def testHoserStoppage(self): |
has_mac = 0 | def handle_read(self): self.__input_lock.acquire() try: # Use a single __inp buffer and integer indexes to make this fast. try: d = self.recv(8192) except socket.error, err: if err[0] in expected_socket_read_errors: return raise if not d: return | |
self.locked = True | self.locked = 1 | def pack(self): # Pack copies all data reachable at the pack time or later. # # Copying occurs in two phases. In the first phase, txns # before the pack time are copied if the contain any reachable # data. In the second phase, all txns after the pack time # are copied. # # Txn and data records contain pointers to pre... |
(self.tid, length, self.status, self.user_len, self.descr_len, | (self.tid, self.length, self.status, self.user_len, self.descr_len, | def _read_header(self): self._file.seek(self._pos) self._hdr = self._file.read(TRANS_HDR_LEN) (self.tid, length, self.status, self.user_len, self.descr_len, self.ext_len) = struct.unpack(TRANS_HDR, self._hdr) self.length = u64(length) |
self.length = u64(length) | def _read_header(self): self._file.seek(self._pos) self._hdr = self._file.read(TRANS_HDR_LEN) (self.tid, length, self.status, self.user_len, self.descr_len, self.ext_len) = struct.unpack(TRANS_HDR, self._hdr) self.length = u64(length) | |
def main(): | def test_suite(): | def main(): TIOBTree = makeSuite(TestIOBTrees, 'test') TOOBTree = makeSuite(TestOOBTrees, 'test') TOIBTree = makeSuite(TestOIBTrees, 'test') TIIBTree = makeSuite(TestIIBTrees, 'test') TIOSet = makeSuite(TestIOSets, 'test') TOOSet = makeSuite(TestOOSets, 'test') TOISet = makeSuite(TestIOSets, 'test') TIISet = makeSuite... |
l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l | l1=list(l1) l2=list(l2) l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l | def lsubtract(l1, l2): l = filter(lambda x, l1=l1: x not in l1, l2) l = l + filter(lambda x, l2=l2: x not in l2, l1) return l |
if __name__ == '__main__': main() | if __name__=='__main__': if len(sys.argv) > 1: globals()[sys.argv[1]]() else: main() | def realseq(itemsob): return map(lambda x: x, itemsob) |
assert root['t'] == t | assert list(root['t'].items()) == list(t.items()) | def testLoadAndStore(self): t = self.t try: root = self._getRoot() root['t'] = t get_transaction().commit() except: self._closeDB(root) self._delDB() raise |
assert root['t'] == t | assert list(root['t'].items()) == list(t.items()) | def testGhostUnghost(self): t = self.t try: root = self._getRoot() root['t'] = t get_transaction().commit() except: self._closeDB(root) self._delDB() raise |
assert len(t) == 1000, len(t) | assert len(t) == 10000, len(t) | def testLen(self): # should sets know their length? t = self.t r = xrange(10000) for x in r: t.insert(x) assert len(t) == 1000, len(t) |
ext = dumps(ext,1) | ext = cPickle.dumps(ext, 1) | def tpc_begin(self, transaction, tid=None, status=' '): if self._is_read_only: raise POSException.ReadOnlyError() self._lock_acquire() try: if self._transaction is transaction: return self._lock_release() self._commit_lock_acquire() self._lock_acquire() self._transaction = transaction self._clear_temp() |
already_pickled=0): | already_pickled=0, user=None, description=None): | def _dostore(self, oid=None, revid=None, data=None, version=None, already_pickled=0): """Do a complete storage transaction. The defaults are: - oid=None, ask the storage for a new oid - revid=None, use a revid of ZERO - data=None, pickle up some arbitrary data (the integer 7) - version=None, use the empty string vers... |
truncate(f, pos, file_size, output) | truncate(f, pos, file_size, outp) | def read_txn_header(f, pos, file_size, outp, ltid): # Read the transaction record f.seek(pos) h = f.read(23) if len(h) < 23: raise EOFError tid, stl, status, ul, dl, el = unpack(">8s8scHHH",h) if el < 0: el=t32-el tl = u64(stl) if pos + (tl + 8) > file_size: error("bad transaction length at %s", pos) if tl < (23 + ... |
print __doc__ % argv[0] | print __doc__ % sys.argv[0] | def main(): try: opts, (inp, outp) = getopt.getopt(sys.argv[1:], "fv:pP:") except getopt.error: die() print __doc__ % argv[0] force = partial = verbose = 0 pack = None for opt, v in opts: if opt == "-v": verbose = int(v) elif opt == "-p": partial = 1 elif opt == "-f": force = 1 elif opt == "-P": pack = time.time() - f... |
prepare_ok = False | raise AbortError(r) | def commit(self, txn): # commit calls _finishCommit() or abort() assert txn._status is Status.ACTIVE txn._status = Status.PREPARING prepare_ok = True self.logger.debug("%s: prepare", txn) try: for r in txn._resources: if prepare_ok and not r.prepare(txn): prepare_ok = False except: txn._status = Status.FAILED raise txn... |
if prepare_ok: self._finishCommit(txn) else: self.abort(txn) | self._finishCommit(txn) | def commit(self, txn): # commit calls _finishCommit() or abort() assert txn._status is Status.ACTIVE txn._status = Status.PREPARING prepare_ok = True self.logger.debug("%s: prepare", txn) try: for r in txn._resources: if prepare_ok and not r.prepare(txn): prepare_ok = False except: txn._status = Status.FAILED raise txn... |
return Rollback([r.savepoint(txn) for r in txn._resources]) | return Rollback(txn, [r.savepoint(txn) for r in txn._resources]) | def savepoint(self, txn): self.logger.debug("%s: savepoint", txn) return Rollback([r.savepoint(txn) for r in txn._resources]) |
txn_factory = Transaction | def savepoint(self, txn): self.logger.debug("%s: savepoint", txn) return Rollback([r.savepoint(txn) for r in txn._resources]) | |
txn = self.txn_factory(self) self.logger.debug("%s: begin", txn) return txn | if self._current is not None: self._current.abort() self._current = self.txn_factory(self) self.logger.debug("%s: begin", self._current) return self._current | def begin(self): txn = self.txn_factory(self) self.logger.debug("%s: begin", txn) return txn |
def suspend(self, txn): if self._current != txn: raise TransactionError("Can't suspend transaction because " "it is not active") self._suspended.add(txn) self._current = None | def abort(self, txn): super(TransactionManager, self).abort(txn) self._current = None | |
def __init__(self, resources): | def __init__(self, txn, resources): self._txn = txn | def __init__(self, resources): self._resources = resources |
if self._pool[tid] is txn: | if self._pool.get(tid) is txn: | def suspend(self, txn): tid = thread.get_ident() if self._pool[tid] is txn: self._suspend.add(txn) del self._pool[tid] else: raise TransactionError("txn %s not owned by thread %s" % (txn, tid)) |
close(self._f[current]) | self._f[current].close() | def checkSize(self, size): # Make sure we aren't going to exceed the target size. # If we are, then flip the cache. if self._pos+size > self._limit: current=not self._current self._current=current if self._p[current] is not None: # Persistent cache file: # Note that due to permission madness, waaa, # we need to remove ... |
transaction_id = base64.decodestring(transaction_id + '==\n') tid, tpos = transaction_id[:8], U64(transaction_id[8:]) | tid = transaction_id[:8] oid = transaction_id[8:] if oid == '' or not self._index.has_key(oid): raise UndoError, 'Undoing a non-object affecting transaction' pos = self._index[oid] | def transactionalUndo(self, transaction_id, transaction): """Undo a transaction, given by transaction_id. |
while 1: self._file.seek(pos) h = self._file.read(DATA_HDR_LEN) doid,serial,prev,tpos,vlen,plen = unpack('>8s8s8s8sH8s', h) tpos = U64(tpos) self._file.seek(tpos) thistid = self._file.read(8) if thistid == tid: break pos = U64(prev) if not pos: raise UndoError, 'Invalid undo transaction id' | def transactionalUndo(self, transaction_id, transaction): """Undo a transaction, given by transaction_id. | |
d={'id': encode(tid+p64(pos))[:22], | e = {} if el: try: e = loads(read(el)) except: pass next = read(8) if next == tl: id = tid else: id = tid + next d={'id': id, | def undoLog(self, first=0, last=-20, filter=None): if last < 0: last=first-last+1 self._lock_acquire() try: packt=self._packt if packt is None: raise UndoError( 'Undo is currently disabled for database maintenance.<p>') pos=self._pos if pos < 39: return [] file=self._file seek=file.seek read=file.read unpack=struct.unp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.