Skip to content

Commit c08e811

Browse files
authored
Revert "Fix eager tasks does not populate name field (#8383)" (#8476)
This reverts commit 1c36387.
1 parent 74c8bf7 commit c08e811

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

celery/app/task.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ def apply(self, args=None, kwargs=None,
788788

789789
request = {
790790
'id': task_id,
791-
'task': self.name,
792791
'retries': retries,
793792
'is_eager': True,
794793
'logfile': logfile,
@@ -825,7 +824,7 @@ def apply(self, args=None, kwargs=None,
825824
if isinstance(retval, Retry) and retval.sig is not None:
826825
return retval.sig.apply(retries=retries + 1)
827826
state = states.SUCCESS if ret.info is None else ret.info.state
828-
return EagerResult(task_id, self.name, retval, state, traceback=tb)
827+
return EagerResult(task_id, retval, state, traceback=tb)
829828

830829
def AsyncResult(self, task_id, **kwargs):
831830
"""Get AsyncResult instance for the specified task.

celery/result.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -983,11 +983,10 @@ def restore(cls, id, backend=None, app=None):
983983
class EagerResult(AsyncResult):
984984
"""Result that we know has already been executed."""
985985

986-
def __init__(self, id, name, ret_value, state, traceback=None):
986+
def __init__(self, id, ret_value, state, traceback=None):
987987
# pylint: disable=super-init-not-called
988988
# XXX should really not be inheriting from AsyncResult
989989
self.id = id
990-
self._name = name
991990
self._result = ret_value
992991
self._state = state
993992
self._traceback = traceback
@@ -1039,7 +1038,6 @@ def __repr__(self):
10391038
@property
10401039
def _cache(self):
10411040
return {
1042-
'name': self._name,
10431041
'task_id': self.id,
10441042
'result': self._result,
10451043
'status': self._state,

t/unit/tasks/test_chord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def join(self, propagate=True, **kwargs):
4646
def _failed_join_report(self):
4747
for value in self.value:
4848
if isinstance(value, Exception):
49-
yield EagerResult('some_id', 'test-task', value, 'FAILURE')
49+
yield EagerResult('some_id', value, 'FAILURE')
5050

5151

5252
class TSRNoReport(TSR):

t/unit/tasks/test_result.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_reduce_direct(self):
136136

137137
def test_children(self):
138138
x = self.app.AsyncResult('1')
139-
children = [EagerResult(str(i), 'test-task', i, states.SUCCESS) for i in range(3)]
139+
children = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)]
140140
x._cache = {'children': children, 'status': states.SUCCESS}
141141
x.backend = Mock()
142142
assert x.children
@@ -147,12 +147,12 @@ def test_propagates_for_parent(self):
147147
x.backend = Mock(name='backend')
148148
x.backend.get_task_meta.return_value = {}
149149
x.backend.wait_for_pending.return_value = 84
150-
x.parent = EagerResult(uuid(), 'test-task', KeyError('foo'), states.FAILURE)
150+
x.parent = EagerResult(uuid(), KeyError('foo'), states.FAILURE)
151151
with pytest.raises(KeyError):
152152
x.get(propagate=True)
153153
x.backend.wait_for_pending.assert_not_called()
154154

155-
x.parent = EagerResult(uuid(), 'test-task', 42, states.SUCCESS)
155+
x.parent = EagerResult(uuid(), 42, states.SUCCESS)
156156
assert x.get(propagate=True) == 84
157157
x.backend.wait_for_pending.assert_called()
158158

@@ -172,7 +172,7 @@ def test_get_children(self):
172172
def test_build_graph_get_leaf_collect(self):
173173
x = self.app.AsyncResult('1')
174174
x.backend._cache['1'] = {'status': states.SUCCESS, 'result': None}
175-
c = [EagerResult(str(i), 'test-task', i, states.SUCCESS) for i in range(3)]
175+
c = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)]
176176
x.iterdeps = Mock()
177177
x.iterdeps.return_value = (
178178
(None, x),
@@ -194,7 +194,7 @@ def test_build_graph_get_leaf_collect(self):
194194

195195
def test_iterdeps(self):
196196
x = self.app.AsyncResult('1')
197-
c = [EagerResult(str(i), 'test-task', i, states.SUCCESS) for i in range(3)]
197+
c = [EagerResult(str(i), i, states.SUCCESS) for i in range(3)]
198198
x._cache = {'status': states.SUCCESS, 'result': None, 'children': c}
199199
for child in c:
200200
child.backend = Mock()
@@ -945,13 +945,13 @@ def test_wait_raises(self):
945945
assert res.wait(propagate=False)
946946

947947
def test_wait(self):
948-
res = EagerResult('x', 'test-task', 'x', states.RETRY)
948+
res = EagerResult('x', 'x', states.RETRY)
949949
res.wait()
950950
assert res.state == states.RETRY
951951
assert res.status == states.RETRY
952952

953953
def test_forget(self):
954-
res = EagerResult('x', 'test-task', 'x', states.RETRY)
954+
res = EagerResult('x', 'x', states.RETRY)
955955
res.forget()
956956

957957
def test_revoke(self):
@@ -962,7 +962,7 @@ def test_revoke(self):
962962
def test_get_sync_subtask_option(self, task_join_will_block):
963963
task_join_will_block.return_value = True
964964
tid = uuid()
965-
res_subtask_async = EagerResult(tid, 'test-task', 'x', 'x', states.SUCCESS)
965+
res_subtask_async = EagerResult(tid, 'x', 'x', states.SUCCESS)
966966
with pytest.raises(RuntimeError):
967967
res_subtask_async.get()
968968
res_subtask_async.get(disable_sync_subtasks=False)

0 commit comments

Comments
 (0)