Test concurrent cache access doesn't break anything.
(test: CacheLintStressTest)
| 377 | |
| 378 | |
| 379 | def test_concurrent_cache_access(test: CacheLintStressTest) -> None: |
| 380 | """Test concurrent cache access doesn't break anything.""" |
| 381 | print("\n📋 TEST 8: Concurrent Cache Access") |
| 382 | print("-" * 70) |
| 383 | |
| 384 | # Run 3 concurrent cache checks |
| 385 | result_queue: multiprocessing.Queue[tuple[str, Any]] = multiprocessing.Queue() |
| 386 | processes: list[multiprocessing.Process] = [] |
| 387 | |
| 388 | for i in range(3): |
| 389 | p = multiprocessing.Process( |
| 390 | target=_concurrent_cache_check, args=("python", result_queue) |
| 391 | ) |
| 392 | p.start() |
| 393 | processes.append(p) |
| 394 | |
| 395 | # Wait for all |
| 396 | for p in processes: |
| 397 | p.join(timeout=15) |
| 398 | |
| 399 | # Check results |
| 400 | results: list[tuple[str, Any]] = [] |
| 401 | while not result_queue.empty(): |
| 402 | results.append(result_queue.get()) |
| 403 | |
| 404 | if len(results) >= 2: |
| 405 | test.pass_test("Concurrent cache access completed without errors") |
| 406 | else: |
| 407 | test.fail_test("Concurrent cache access", f"Only {len(results)}/3 completed") |
| 408 | |
| 409 | |
| 410 | def main() -> int: |