Skip to content

Commit

Permalink
dvc-10427 Send the shutdown message to the appropriate worker.
Browse files Browse the repository at this point in the history
  • Loading branch information
nablabits committed Sep 25, 2024
1 parent d56d993 commit 307c98b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dvc_task/worker/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ def _tasksets(nodes):
logger.info("monitor: shutting down due to empty queue.")
break
logger.debug("monitor: sending shutdown to '%s'.", nodename)
self.app.control.shutdown()
self.app.control.shutdown(destination=[nodename])
logger.debug("monitor: done")
7 changes: 5 additions & 2 deletions tests/worker/test_temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from celery import Celery
from celery.concurrency.prefork import TaskPool
from celery.utils.nodenames import default_nodename
from celery.worker.worker import WorkController
from pytest_mock import MockerFixture

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

0 comments on commit 307c98b

Please sign in to comment.