f^ NddlmZGddZGddZGddeZy) )dequec0eZdZdZdZdZdZdZddZy) TransactionaFilesystem transaction write context Gathers files for deferred commit or discard, so that several write operations can be finalized semi-atomically. This works by having this instance as the ``.transaction`` attribute of the given filesystem c 0||_t|_y)O Parameters ---------- fs: FileSystem instance N)fsrfiles)selfrkwargss [/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/fsspec/transaction.py__init__zTransaction.__init__ s W c&|j|SN)startr s r __enter__zTransaction.__enter__s  rc|j|du|jr*d|j_d|j_d|_yy)z;End transaction and commit, if exit is not due to exceptionN)commitF)completer_intrans _transaction)r exc_typeexc_valexc_tbs r __exit__zTransaction.__exit__sB X- . 77$DGG #'DGG DG rcDt|_d|j_y)z&Start a transaction on this FileSystemTN)rr rrrs r rzTransaction.start"sW rc|jrJ|jj}|r|jn|j|jrJd|j_d|j_d|_yz8Finish transaction: commit or discard all deferred filesFN)r popleftrdiscardrrr)r rfs r rzTransaction.complete'sZjj ""$A  jj !#rNT) __name__ __module__ __qualname____doc__r rrrrrr rrs  rrc$eZdZdZdZdZdZy) FileActorcg|_yr)r rs r r zFileActor.__init__5s  rcz|jD]}|j|jjyr)r rclearr r"s r rzFileActor.commit8s)A HHJ rcz|jD]}|j|jjyr)r r!r-r.s r r!zFileActor.discard=s)A IIK rc:|jj|yr)r appendr.s r r1zFileActor.appendBs !rN)r$r%r&r rr!r1r(rr r*r*4s  rr*c&eZdZfdZddZxZS)DaskTransactioncddl}t| ||j}|j t dj |_y)rrNT)actor) distributedsuperr default_clientsubmitr*resultr )r rr6client __class__s r r zDaskTransaction.__init__Gs@  ++-]]9D]9@@B rc|r)|jjjn(|jjjd|j_d|_yr)r rr:r!rr)r rs r rzDaskTransaction.completeSsJ  JJ    & & ( JJ   ' ' ) rr#)r$r%r&r r __classcell__)r<s@r r3r3Fs Crr3N) collectionsrrr*r3r(rr r@s)--`$kr