Skip to content

Commit

Permalink
Bugfix: If get_redis_hash finds an invalid key, put it back in the qu…
Browse files Browse the repository at this point in the history
…eue. (#57)

* if a key is invalid for some reason, put it back instead of working on it.

* update tests for get_redis_hash putback keys if invalid change
  • Loading branch information
willgraf committed Aug 27, 2019
1 parent 791293e commit c4883ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion redis_consumer/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def get_redis_hash(self):
self.logger.warning('Found invalid hash in %s: `%s` with '
'hvals: %s', self.queue, redis_hash,
self.redis.hgetall(redis_hash))
self.redis.lrem(self.processing_queue, 1, redis_hash)
# self.redis.lrem(self.processing_queue, 1, redis_hash)
self._put_back_hash(redis_hash)

def _handle_error(self, err, redis_hash):
"""Update redis with failure information, and log errors.
Expand Down
2 changes: 1 addition & 1 deletion redis_consumer/consumers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_get_redis_hash(self):

rhash = consumer.get_redis_hash()
assert rhash == items[0]
assert redis_client.work_queue == []
assert redis_client.work_queue == items[1:]
assert redis_client.processing_queue == items[0:1]

def test_purge_processing_queue(self):
Expand Down

0 comments on commit c4883ae

Please sign in to comment.