Comment 2 for bug 1858667

Revision history for this message
Lee Yarwood (lyarwood) wrote :

https://github.com/openstack/nova/blob/1fa6799e4171d7c93f4d6330f2437891733d7d27/nova/tests/fixtures.py#L403-L483

^ is essentially doing the following:

>>> 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

While https://github.com/harlowja/fasteners/commit/d67b9d08ddcf906240e5d3f2b0b118a7254b4390 suggests only the following is possible:

>>> with lock.write_lock():
... with lock.read_lock():
... with lock.write_lock():
... pass
...