MCPcopy Create free account
hub / github.com/tox-dev/filelock / test_threaded_shared_lock_obj

Function test_threaded_shared_lock_obj

tests/test_filelock.py:290–311  ·  view source on GitHub ↗
(lock_type: type[BaseFileLock], tmp_path: Path)

Source from the content-addressed store, hash-verified

288@pytest.mark.timeout(60)
289@pytest.mark.parametrize("lock_type", [FileLock, SoftFileLock])
290def test_threaded_shared_lock_obj(lock_type: type[BaseFileLock], tmp_path: Path) -> None:
291 if sys.platform == "win32" and lock_type.__name__ == "SoftFileLock": # pragma: win32 cover
292 pytest.skip(
293 "SoftFileLock uses file-existence locking — on Windows, unlink can silently fail under heavy "
294 "thread contention (EACCES from antivirus/indexer), orphaning the lock file with no recovery path"
295 )
296
297 lock_path = tmp_path / "a"
298 lock = lock_type(str(lock_path))
299
300 def thread_work() -> None:
301 for _ in range(100):
302 with lock:
303 assert lock.is_locked
304
305 threads = [ExThread(target=thread_work, name=f"t{i}") for i in range(100)]
306 for thread in threads:
307 thread.start()
308 for thread in threads:
309 thread.join()
310
311 assert not lock.is_locked
312
313
314@pytest.mark.timeout(60)

Callers

nothing calls this directly

Calls 2

ExThreadClass · 0.85
joinMethod · 0.80

Tested by

no test coverage detected