diff --git a/src/core/runner.py b/src/core/runner.py index 2dc9327..4b7ec84 100644 --- a/src/core/runner.py +++ b/src/core/runner.py @@ -96,4 +96,21 @@ class RobustCompressorTestRunner(DiscoverRunner): "WHERE datname = %s AND pid <> pg_backend_pid()", [test_db_name], ) - super().teardown_databases(old_config, **kwargs) + # On local Windows + SQLite, super() ends in os.remove(test_db.sqlite3), + # which raises PermissionError [WinError 32] when another handle still + # holds the file (a concurrent run, a lingering connection, AV / Search + # indexer). Retry briefly, then leave the stale file for the next run to + # overwrite rather than crash an otherwise-green run. CI is Postgres on + # Linux — DROP DATABASE, no file remove, and Linux unlinks open files + # without error — so this loop never triggers there. Mirrors + # _robust_save's PermissionError retry. + for attempt in range(10): + try: + super().teardown_databases(old_config, **kwargs) + return + except PermissionError: + if attempt == 9: + print("teardown_databases: test DB file still locked after " + "retries — leaving it for the next run to overwrite.") + return + time.sleep(0.1)