Fix tests for Windows

This commit is contained in:
Adrian Chaves 2026-08-04 19:14:48 +02:00
parent 9f1742bf8d
commit e174d76ed4
1 changed files with 5 additions and 1 deletions

View File

@ -4,6 +4,7 @@ Queues that handle requests
from __future__ import annotations
import gc
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
@ -242,8 +243,11 @@ def test_sqlite_queue_survives_unclean_shutdown(
key = str(tmp_path / "queue")
queue = queue_cls.from_crawler(crawler=crawler, key=key)
queue.push(Request("https://toscrape.com"))
# No close(), as if the process had been killed.
# No close(), as if the process had been killed. The SQLite connection is
# part of a reference cycle, so a garbage collection is needed to release
# the underlying file, which on Windows cannot be removed while open.
del queue
gc.collect()
queue = queue_cls.from_crawler(crawler=crawler, key=key)
try: