mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-12 21:44:21 -06:00
Ensures tags created in the thread are cleaned up
This commit is contained in:
@@ -703,16 +703,26 @@ def start_consumer(
|
||||
sleep(0.5) # Give thread time to start
|
||||
return thread
|
||||
|
||||
yield _start
|
||||
try:
|
||||
yield _start
|
||||
finally:
|
||||
# Cleanup all threads that were started
|
||||
for thread in threads:
|
||||
thread.stop()
|
||||
|
||||
# Cleanup all threads that were started
|
||||
for thread in threads:
|
||||
thread.stop()
|
||||
failed_threads = []
|
||||
for thread in threads:
|
||||
thread.join(timeout=5.0)
|
||||
if thread.is_alive():
|
||||
failed_threads.append(thread)
|
||||
|
||||
for thread in threads:
|
||||
thread.join(timeout=5.0)
|
||||
if thread.is_alive():
|
||||
pytest.fail("Consumer thread did not stop within timeout")
|
||||
# Clean up any Tags created by threads (they bypass test transaction isolation)
|
||||
Tag.objects.all().delete()
|
||||
|
||||
if failed_threads:
|
||||
pytest.fail(
|
||||
f"{len(failed_threads)} consumer thread(s) did not stop within timeout",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
Reference in New Issue
Block a user