Clear the FileWorker private queue between tests (#860)

The test harness resets the shared file worker public queue for each test,
but the FileWorker's private LifoQueue is per-process state that survived
from one test to the next. Tests that process only a count task leave its
chained refresh task queued, and it later ran inside an unrelated test.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-10-23 13:03:55 -06:00 • committed by GitHub
parent 58192a7052
commit 1f3762ff20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -50,6 +50,7 @@ from wrolpi.downloader import DownloadContext, DownloadManager, DownloadResult,
downloads_manager_config_context, download_cache_config_context
from wrolpi.errors import UnrecoverableDownloadError
from wrolpi.files.models import Directory, FileGroup
from wrolpi.files.worker import file_worker
from wrolpi.switches import await_switches as await_switches_
from wrolpi.tags import Tag, upsert_tag
from wrolpi.vars import PROJECT_DIR
@ -299,6 +300,10 @@ async def async_client(test_directory, test_session, clear_background_tasks) ->
api_app.signalize()
attach_shared_contexts(api_app)
initialize_configs_contexts(api_app)
# The FileWorker's private queue is per-process state that the shared-context reset does not touch;
# each test starts with no FileTasks left over from a previous test.
while not file_worker.private_queue.empty():
file_worker.private_queue.get_nowait()
client = SanicASGITestClient(api_app)
wrapped_client = AutoAwaitTestClient(client, test_session)