Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Unified Diff: tools/gardening/lib/src/client.dart

Issue 2998993002: Use timeout to read most recent build from http (Closed)
Patch Set: Fix test Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/gardening/lib/src/client.dart
diff --git a/tools/gardening/lib/src/client.dart b/tools/gardening/lib/src/client.dart
index f73a50df5efdeb18501806c07e42d9c9ad58c9f5..95424fb72ca195613d68b57589845c315abcad66 100644
--- a/tools/gardening/lib/src/client.dart
+++ b/tools/gardening/lib/src/client.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:async';
+import 'dart:async' hide TimeoutException;
import 'dart:io' hide HttpException;
import 'buildbot_data.dart';
@@ -28,16 +28,40 @@ class HttpBuildbotClient implements BuildbotClient {
@override
Future<BuildResult> readResult(BuildUri buildUri) async {
- try {
- return await readBuildResultFromHttp(_client, buildUri);
- } on HttpException {
- return null;
- } on SocketException {
- return null;
+ Duration timeout;
+ if (buildUri.buildNumber < 0) {
+ timeout = new Duration(seconds: 1);
+ }
+
+ void skipToPreviousBuildNumber() {
+ BuildUri prevBuildUri = buildUri.prev();
+ log('Skip build number '
+ '${buildUri.buildNumber} -> ${prevBuildUri.buildNumber}');
+ buildUri = buildUri.prev();
+ }
+
+ while (true) {
+ try {
+ return await readBuildResultFromHttp(_client, buildUri, timeout);
+ } on TimeoutException {
+ if (timeout != null) {
+ skipToPreviousBuildNumber();
+ continue;
+ }
+ return null;
+ } on HttpException {
+ if (timeout != null) {
+ skipToPreviousBuildNumber();
+ continue;
+ }
+ return null;
+ } on SocketException {
+ return null;
+ }
}
}
- int get mostRecentBuildNumber => -2;
+ int get mostRecentBuildNumber => -1;
@override
void close() {

Powered by Google App Engine
This is Rietveld 408576698