From d4970c15dea6c5591a14c4a20b40fe6b1fe6f2f0 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Sat, 2 Apr 2022 14:50:57 -0400 Subject: [PATCH] Reduce the flush interval in tests. (#60) To slightly speed up test runs. --- CHANGELOG.rst | 3 ++- t/integration/tasks.py | 16 ++++++++++++---- t/integration/test_batches.py | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8db71df..cda9ade 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,7 +17,8 @@ Maintenance * Fix running of tests via tox. (`#40 `_, `#58 `_) -* Simplify tests. (`#56 `_) +* Simplify tests. (`#56 `_, + `#60 `_) * Improve PyPI metadata. (`#43 `_, `#52 `_) * Ignore virtualenvs in `.gitignore`. Contributed by `Tony Narlock `_. diff --git a/t/integration/tasks.py b/t/integration/tasks.py index e1b5944..85e61de 100644 --- a/t/integration/tasks.py +++ b/t/integration/tasks.py @@ -6,9 +6,13 @@ logger = get_task_logger(__name__) -@shared_task(base=Batches, flush_every=2, flush_interval=1) +@shared_task(base=Batches, flush_every=2, flush_interval=0.1) def add(requests): - """Add the first argument of each call.""" + """ + Add the first argument of each task. + + Marks the result of each task as the sum. + """ from celery import current_app result = 0 @@ -22,9 +26,13 @@ def add(requests): return result -@shared_task(base=Batches, flush_every=2, flush_interval=1) +@shared_task(base=Batches, flush_every=2, flush_interval=0.1) def cumadd(requests): - """Calculate the cumulative sum of the first arguments of each call.""" + """ + Calculate the cumulative sum of the first argument of each task. + + Marks the result of each task as the sum at the point. + """ from celery import current_app result = 0 diff --git a/t/integration/test_batches.py b/t/integration/test_batches.py index ef86c48..6cb63a6 100644 --- a/t/integration/test_batches.py +++ b/t/integration/test_batches.py @@ -72,8 +72,8 @@ def test_flush_interval(celery_app, celery_worker): result = add.delay(1) - # The flush interval is 1 second, this is longer. - sleep(2) + # The flush interval is 0.1 second, this is longer. + sleep(0.2) # Let the worker work. _wait_for_ping()