code: def test_basic():
      lock = ReadWriteLock()
  
      with lock.write():
          pass
  
      # Write after write
      with lock.write():
          pass
  
      # Read after write
      with lock.read():
          pass
  
      # Write after read
      with lock.write():
          pass
  
      with pytest.raises(RuntimeError, match="unlocked read lock"):
          lock.release_read()
  
      with pytest.raises(RuntimeError, match="unlocked write lock"):
          lock.release_write()
  
file_path: distributed/distributed/shuffle/tests/test_read_write_lock.py
imports: from __future__ import annotations
  import threading
  import pytest
  from distributed.shuffle._disk import ReadWriteLock
label_desc: Use image node_id 3 for calling a global function with example usage: test_basic() without return types