launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #19132
[Merge] lp:~wgrant/launchpad/job-configurable-lease-duration into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/job-configurable-lease-duration into lp:launchpad.
Commit message:
Allow BaseRunnableJob derivatives to override the lease duration.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/job-configurable-lease-duration/+merge/266702
Allow BaseRunnableJob derivatives to override the lease duration. MP jobs already lengthened it, and webhooks will shorten it.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/job-configurable-lease-duration into lp:launchpad.
=== modified file 'lib/lp/code/model/branchmergeproposaljob.py'
--- lib/lp/code/model/branchmergeproposaljob.py 2015-07-09 20:06:17 +0000
+++ lib/lp/code/model/branchmergeproposaljob.py 2015-08-03 10:50:59 +0000
@@ -342,6 +342,8 @@
max_retries = 20
+ lease_duration = timedelta(minutes=10)
+
def checkReady(self):
"""Is this job ready to run?"""
bmp = self.branch_merge_proposal
@@ -357,9 +359,6 @@
raise BranchHasPendingWrites(
'The source branch of %s has pending writes.' % url)
- def acquireLease(self, duration=600):
- return self.job.acquireLease(duration)
-
def run(self):
"""See `IRunnableJob`."""
self.checkReady()
@@ -577,8 +576,7 @@
config = config.IBranchMergeProposalJobSource
- def acquireLease(self, duration=600):
- return self.job.acquireLease(duration)
+ lease_duration = timedelta(minutes=10)
def run(self):
revision_set = getUtility(IRevisionSet)
=== modified file 'lib/lp/services/job/runner.py'
--- lib/lp/services/job/runner.py 2015-08-03 07:53:59 +0000
+++ lib/lp/services/job/runner.py 2015-08-03 10:50:59 +0000
@@ -109,6 +109,7 @@
celery_responses = None
+ lease_duration = timedelta(minutes=5)
retry_delay = timedelta(minutes=10)
soft_time_limit = timedelta(minutes=5)
@@ -193,6 +194,11 @@
return oops_config.create(
context=dict(exc_info=info))
+ def acquireLease(self, duration=None):
+ if duration is None:
+ duration = self.lease_duration.total_seconds()
+ self.job.acquireLease(duration)
+
def taskId(self):
"""Return a task ID that gives a clue what this job is about.
Follow ups