Chromium Code Reviews| Index: third_party/buildbot_8_4p1/buildbot/process/builder.py |
| diff --git a/third_party/buildbot_8_4p1/buildbot/process/builder.py b/third_party/buildbot_8_4p1/buildbot/process/builder.py |
| index e92e2d1a34fa1e47532343f21a4beca500dd0080..b1bc75be4b42e899985d514c5a55792a728761dd 100644 |
| --- a/third_party/buildbot_8_4p1/buildbot/process/builder.py |
| +++ b/third_party/buildbot_8_4p1/buildbot/process/builder.py |
| @@ -14,7 +14,7 @@ |
| # Copyright Buildbot Team Members |
| -import random, weakref |
| +import inspect, random, weakref |
| from zope.interface import implements |
| from twisted.python import log, failure |
| from twisted.spread import pb |
| @@ -853,12 +853,33 @@ class Builder(pb.Referenceable, service.MultiService): |
| breq_object = unclaimed_request_objects.pop( |
| unclaimed_requests.index(breq)) |
| + # Make sure the merge-requests function can take the queue length. Old |
|
tandrii(chromium)
2016/10/13 13:35:22
...queue length and len(merged_requests).
Michael Achenbach
2016/10/13 13:53:35
wrote "lengths" now
|
| + # style functions only take two parameters. |
| + mergeRequests_with_length_fn = lambda a, b, *_ : mergeRequests_fn(a, b) |
|
tandrii(chromium)
2016/10/13 13:35:22
inspect on bound class functions or on functions w
Michael Achenbach
2016/10/13 13:53:35
Good catch. Now implemented your suggestion to use
|
| + try: |
| + n_args = len(inspect.getargspec(mergeRequests_fn).args) |
| + if n_args > 3: |
| + # New style function that accepts total and merged parameters. |
| + mergeRequests_with_length_fn = mergeRequests_fn |
| + except Exception as e: |
| + log.err(e, 'Exception analyzing mergeRequests function.') |
| + |
| + # This might not reflect exact number of items that could be merged |
| + # (this depends on the canBeMergedWith algorithm), but it can help |
| + # indicating how loaded this builder is. |
| + queue_length = len(unclaimed_request_objects) |
| + |
| # gather the mergeable requests |
| merged_request_objects = [breq_object] |
| for other_breq_object in unclaimed_request_objects: |
| wfd = defer.waitForDeferred( |
| defer.maybeDeferred(lambda : |
| - mergeRequests_fn(breq_object, other_breq_object))) |
| + mergeRequests_with_length_fn( |
| + breq_object, |
| + other_breq_object, |
| + queue_length, |
| + len(merged_request_objects), |
| + ))) |
| yield wfd |
| if wfd.getResult(): |
| merged_request_objects.append(other_breq_object) |