Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Commit

Permalink
fix(taskmanager): add early guard for over-failed tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKevJames committed Jul 5, 2018
1 parent 3c7878b commit 9941564
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions gcloud/rest/taskqueue/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,17 @@ def find_and_process_work(self):
leasers = []
payloads = []
for task in tasks:
payloads.append(
json.loads(decode(task['pullMessage']['payload']).decode()))
payload = json.loads(
decode(task['pullMessage']['payload']).decode())
retries = int(task['status']['attemptDispatchCount'])
if self.retry_limit is not None and retries > 2 * self.retry_limit:
log.warning('force failing task %s with %d/%d retries',
task['name'], retries, self.retry_limit)
self.fail_task(payload, 'force failed after too many attempts')
self.tq.delete(task['name'])
continue

payloads.append(payload)

try:
data = self.manager.dict()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setuptools.setup(
name='gcloud-rest',
version='1.4.0',
version='1.5.0',
description='RESTful Python Client for Google Cloud',
long_description=README,
namespace_packages=[
Expand Down

0 comments on commit 9941564

Please sign in to comment.