mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-01-18 22:14:22 -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
|
sleep(0.5) # Give thread time to start
|
||||||
return thread
|
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
|
failed_threads = []
|
||||||
for thread in threads:
|
for thread in threads:
|
||||||
thread.stop()
|
thread.join(timeout=5.0)
|
||||||
|
if thread.is_alive():
|
||||||
|
failed_threads.append(thread)
|
||||||
|
|
||||||
for thread in threads:
|
# Clean up any Tags created by threads (they bypass test transaction isolation)
|
||||||
thread.join(timeout=5.0)
|
Tag.objects.all().delete()
|
||||||
if thread.is_alive():
|
|
||||||
pytest.fail("Consumer thread did not stop within timeout")
|
if failed_threads:
|
||||||
|
pytest.fail(
|
||||||
|
f"{len(failed_threads)} consumer thread(s) did not stop within timeout",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
|
|||||||
Reference in New Issue
Block a user