f @ddlmZddlZGddZGddZy))contextmanagerNcNeZdZdZdZedZedZdZdZ dZ dZ y ) RWLockzdLock enabling multiple readers but only 1 exclusive writer Source: https://cutt.ly/Ij70qaq ct|_t|_tj|_tj|_tj|_yN) _LightSwitch _read_switch _write_switch threadingLock _no_readers _no_writersRLock_readers_queueselfs Y/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/mongomock/thread.py__init__zRWLock.__init__ sC(N)^$>>+$>>+'oo/c#K|j d |jy#t$rwxYw#|jwxYwwr)_reader_acquire Exception_reader_releasers rreaderz RWLock.readerJ  #   "     "!A *A  58A  A c#K|j d |jy#t$rwxYw#|jwxYwwr)_writer_acquirer_writer_releasers rwriterz RWLock.writerrrc|jj|jj|jj|j|jj |jj y)z3Readers should block whenever a writer has acquiredN)racquirer r rreleasers rrzRWLock._reader_acquire'sd ##%   " !!$"2"23   " ##%rcN|jj|jyr)r r#rrs rrzRWLock._reader_release/s !!$"2"23rc|jj|j|jjy)aAcquire the writer lock. Only the first writer will lock the readtry and then all subsequent writers can simply use the resource as it gets freed by the previous writer. The very last writer must release the readtry semaphore, thus opening the gate for readers to try reading. No reader can engage in the entry section if the readtry semaphore has been set by a writer previously N)r r"r rrs rrzRWLock._writer_acquire2s0 ""4#3#34   "rc|jj|jj|jyr)rr#r r rs rrzRWLock._writer_releaseAs.   " ""4#3#34rN) __name__ __module__ __qualname____doc__rrrr rrrrrrrrsH 0####&4 #5rrc"eZdZdZdZdZdZy)rzAn auxiliary "light switch"-like object The first thread turns on the "switch", the last one turns it off. Source: https://cutt.ly/Ij70qaq cDd|_tj|_y)Nr)_counterr r_mutexrs rrz_LightSwitch.__init__Os oo' rc|jj|xjdz c_|jdk(r|j|jjy)Nr/r"r.r#rlocks rr"z_LightSwitch.acquireSE   ==A  LLN rc|jj|xjdzc_|jdk(r|j|jjy)Nr1rr2r3s rr#z_LightSwitch.releaseZr5rN)r'r(r)r*rr"r#r+rrrrFs(rr) contextlibrr rrr+rrr8s %=5=5@r