Skip to content

Commit ef72917

Browse files
authored
dvc-10427 Fix Celery Monitor Shutdowns (#142)
* dvc-10427 Add 2" delay to expirations check As per treeverse/dvc#10427 investigation we realised that kombu creates expiration dates for messages 1" in the future which affects cleaning the directories on shutdown. * Add a tip to run a single test to the documentation * Exclude pyenv virtual environments * dvc-10427 Send the shutdown message to the appropriate worker. Please check: treeverse/dvc#10427 (comment) * Revert "dvc-10427 Add 2" delay to expirations check" This reverts commit f15acd7 as per treeverse/dvc#10427 (comment)
1 parent 386cd07 commit ef72917

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ venv/
112112
ENV/
113113
env.bak/
114114
venv.bak/
115+
.python-version
115116

116117
# Spyder project settings
117118
.spyderproject

CONTRIBUTING.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ For example, invoke the unit test suite like this:
7878
7979
$ nox --session=tests
8080
81+
During the development process, though, you may be happy to just run the tests you are
82+
writing in your environment:
83+
84+
.. code:: console
85+
86+
$ nox --session=tests-3.12 -- -k my_cool_test
87+
8188
Unit tests are located in the ``tests`` directory,
8289
and are written using the pytest_ testing framework.
8390

src/dvc_task/worker/temporary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,5 @@ def _tasksets(nodes):
125125
logger.info("monitor: shutting down due to empty queue.")
126126
break
127127
logger.debug("monitor: sending shutdown to '%s'.", nodename)
128-
self.app.control.shutdown()
128+
self.app.control.shutdown(destination=[nodename])
129129
logger.debug("monitor: done")

tests/worker/test_temporary.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66
from celery import Celery
77
from celery.concurrency.prefork import TaskPool
8+
from celery.utils.nodenames import default_nodename
89
from celery.worker.worker import WorkController
910
from pytest_mock import MockerFixture
1011

@@ -52,5 +53,7 @@ def test_monitor(
5253
"""Should shutdown worker when queue empty."""
5354
worker = TemporaryWorker(celery_app, timeout=1)
5455
shutdown = mocker.spy(celery_app.control, "shutdown")
55-
worker.monitor(celery_worker.hostname) # type: ignore[attr-defined]
56-
shutdown.assert_called_once()
56+
hostname = celery_worker.hostname # type: ignore[attr-defined]
57+
worker.monitor(hostname)
58+
nodename = default_nodename(hostname)
59+
shutdown.assert_called_once_with(destination=[nodename])

0 commit comments

Comments
 (0)