>>> import fasteners
>>> lock = fasteners.ReaderWriterLock()
>>> with lock.read_lock():
... with lock.write_lock():
... pass
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib64/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/home/lyarwood/redhat/devel/src/openstack/nova/.tox/functional/lib/python3.8/site-packages/fasteners/lock.py", line 231, in write_lock
raise RuntimeError("Reader %s to writer privilege"
RuntimeError: Reader <_MainThread(MainThread, started 139834271795008)> to writer privilege escalation not allowed
https:/ /github. com/openstack/ nova/blob/ 1fa6799e4171d7c 93f4d6330f24378 91733d7d27/ nova/tests/ fixtures. py#L403- L483
^ is essentially doing the following:
>>> import fasteners ReaderWriterLoc k() python3. 8/contextlib. py", line 113, in __enter__ lyarwood/ redhat/ devel/src/ openstack/ nova/.tox/ functional/ lib/python3. 8/site- packages/ fasteners/ lock.py" , line 231, in write_lock "Reader %s to writer privilege" MainThread, started 139834271795008)> to writer privilege escalation not allowed
>>> lock = fasteners.
>>> with lock.read_lock():
... with lock.write_lock():
... pass
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/usr/lib64/
return next(self.gen)
File "/home/
raise RuntimeError(
RuntimeError: Reader <_MainThread(
While https:/ /github. com/harlowja/ fasteners/ commit/ d67b9d08ddcf906 240e5d3f2b0b118 a7254b4390 suggests only the following is possible:
>>> with lock.write_lock():
... with lock.read_lock():
... with lock.write_lock():
... pass
...