Skip to content

Commit a95df51

Browse files
author
余森彬
committed
Replace NotImplemented to NotImplementedError, and fix test_send_worker_shutting_down_signal test case with additional patch on active_thread_count function in celery.apps.worker module.
1 parent 7f80408 commit a95df51

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

celery/concurrency/future.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class greenFutureExecutor(defaultFutureExecutor):
116116

117117
@classmethod
118118
def getcurrent(cls):
119-
raise NotImplemented()
119+
raise NotImplementedError()
120120

121121
@classmethod
122122
def get_greentlet_hub(cls):
123-
raise NotImplemented()
123+
raise NotImplementedError()
124124

125125
@classmethod
126126
def apply_future(cls, func, *args, **kwargs):

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
case>=1.3.1
22
pytest>=3.0
33
pytest_localserver>=0.3.7
4+
pytest-mock>=1.6.2
45
tornado>=4.0.0

t/unit/bin/test_worker.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,14 @@ def test_worker_term_hard_handler_when_single_threaded(self):
644644
with pytest.raises(WorkerTerminate):
645645
handlers['SIGQUIT']('SIGQUIT', object())
646646

647-
def test_send_worker_shutting_down_signal(self):
648-
with patch('celery.apps.worker.signals.worker_shutting_down') as wsd:
647+
def test_send_worker_shutting_down_signal(self, mocker):
648+
with patch('celery.signals.worker_shutting_down') as wsd:
649649
worker = self._Worker()
650650
handlers = self.psig(cd.install_worker_term_handler, worker)
651+
active_thread_count = mocker.patch(
652+
'celery.apps.worker.active_thread_count')
653+
active_thread_count.return_value = 1
654+
651655
try:
652656
with pytest.raises(WorkerShutdown):
653657
handlers['SIGTERM']('SIGTERM', object())

0 commit comments

Comments
 (0)