Skip to content

Commit

Permalink
bugfix: when set config result_expires = 0, chord.get will hang. (#6373)
Browse files Browse the repository at this point in the history
* bugfix: when set config result_expires = 0, chord.get will hang.

`EXPIRE key 0` will delete a key in redis, then chord will never get the
result.

fix: #5237

* test: add testcase for expire when set config with zero.
  • Loading branch information
laixintao authored and thedrow committed May 31, 2021
1 parent 2c39a70 commit edaf077
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions t/unit/backends/test_redis.py
Expand Up @@ -713,6 +713,24 @@ def test_on_chord_part_return_expire_set_to_zero(self, restore):

self.b.expires = old_expires

@patch('celery.result.GroupResult.restore')
def test_on_chord_part_return_expire_set_to_zero(self, restore):
old_expires = self.b.expires
self.b.expires = 0
tasks = [self.create_task(i) for i in range(10)]

for i in range(10):
self.b.on_chord_part_return(tasks[i].request, states.SUCCESS, i)
assert self.b.client.zadd.call_count
self.b.client.zadd.reset_mock()
assert self.b.client.zrangebyscore.call_count
jkey = self.b.get_key_for_group('group_id', '.j')
tkey = self.b.get_key_for_group('group_id', '.t')
self.b.client.delete.assert_has_calls([call(jkey), call(tkey)])
self.b.client.expire.assert_not_called()

self.b.expires = old_expires

@patch('celery.result.GroupResult.restore')
def test_on_chord_part_return_no_expiry__unordered(self, restore):
self.app.conf.result_backend_transport_options = dict(
Expand Down

0 comments on commit edaf077

Please sign in to comment.