code: def test_rwlock_reentrant(tmp_path):
      path = os.fspath(tmp_path)
      foo = "foo"
  
      with rwlock(path, localfs, "cmd1", [], [foo], False):
          with rwlock(path, localfs, "cmd1", [], [foo], False):
              pass
          with _edit_rwlock(path, localfs, False) as lock:
              assert lock == {
                  "read": {},
                  "write": {"foo": {"cmd": "cmd1", "pid": os.getpid()}},
              }
  
      with rwlock(path, localfs, "cmd", [foo], [], False):
          with rwlock(path, localfs, "cmd", [foo], [], False):
              pass
          with _edit_rwlock(path, localfs, False) as lock:
              assert lock == {
                  "read": {"foo": [{"cmd": "cmd", "pid": os.getpid()}]},
                  "write": {},
              }
  
file_path: dvc/tests/unit/test_rwlock.py
imports: import json
  import os
  import pytest
  from dvc.fs import localfs
  from dvc.lock import LockError
  from dvc.rwlock import RWLockFileCorruptedError, RWLockFileFormatError, _edit_rwlock, rwlock
label_desc: Use image node_id 2 for calling a global function with example usage: test_rwlock_reentrant(tmp_path) without return types