diff --git a/tools/buildmessage.js b/tools/buildmessage.js index b2b38f7075..c2b0950c7c 100644 --- a/tools/buildmessage.js +++ b/tools/buildmessage.js @@ -505,42 +505,62 @@ var forkJoin = function (options, iterable, fn) { var messageSet = currentMessageSet.get(); var progress = currentProgress.get(); - _.each(iterable, function (/*arguments*/) { - var fut = new Future(); - var fnArguments = arguments; - Fiber(function () { - currentProgress.withValue(progress, function () { - currentMessageSet.withValue(messageSet, function () { - currentJob.withValue(job, function () { - try { - var result = enterJob({title: (options.title || '') + ' child' }, function () { - return fn.apply(null, fnArguments); - }); - fut['return'](result); - } catch (e) { - fut['throw'](e); - } + var parallel = (options.parallel !== undefined) ? options.parallel : true; + if (parallel) { + _.each(iterable, function (/*arguments*/) { + var fut = new Future(); + var fnArguments = arguments; + Fiber(function () { + currentProgress.withValue(progress, function () { + currentMessageSet.withValue(messageSet, function () { + currentJob.withValue(job, function () { + try { + var result = enterJob({title: (options.title || '') + ' child' }, function () { + return fn.apply(null, fnArguments); + }); + fut['return'](result); + } catch (e) { + fut['throw'](e); + } + }); }); }); - }); - }).run(); - futures.push(fut); - }); + }).run(); + futures.push(fut); + }); - _.each(futures, function (future) { - try { - var result = future.wait(); - results.push(result); - errors.push(null); - } catch (e) { - results.push(null); - errors.push(e); + _.each(futures, function (future) { + try { + var result = future.wait(); + results.push(result); + errors.push(null); + } catch (e) { + results.push(null); + errors.push(e); - if (firstError === null) { - firstError = e; + if (firstError === null) { + firstError = e; + } } - } - }); + }); + } else { + // not parallel + _.each(iterable, function (/*arguments*/) { + var fnArguments = arguments; + try { + var result = fn.apply(null, fnArguments); + results.push(result); + errors.push(null); + } catch (e) { + results.push(null); + errors.push(e); + + if (firstError === null) { + firstError = e; + } + } + }); + } }); if (firstError) { diff --git a/tools/catalog-local.js b/tools/catalog-local.js index 734a2730fe..6db35dd253 100644 --- a/tools/catalog-local.js +++ b/tools/catalog-local.js @@ -456,7 +456,8 @@ _.extend(LocalCatalog.prototype, { }; // Load the package sources for packages and their tests into packageSources. - buildmessage.forkJoin({ 'title': 'Initializing packages'}, self.effectiveLocalPackages, function (x) { + // XXX: We should make this work with parallel: true; right now it seems to hit node problems + buildmessage.forkJoin({ 'title': 'Initializing packages', parallel: false }, self.effectiveLocalPackages, function (x) { initSourceFromDir(x); }); diff --git a/tools/tropohouse.js b/tools/tropohouse.js index 03dc0dde36..98b799debe 100644 --- a/tools/tropohouse.js +++ b/tools/tropohouse.js @@ -311,7 +311,7 @@ _.extend(exports.Tropohouse.prototype, { options = options || {}; var serverArch = options.serverArch || archinfo.host(); var downloadedPackages = {}; - buildmessage.forkJoin({ title: 'Downloading packages'}, + buildmessage.forkJoin({ title: 'Downloading packages', parallel: true }, versionMap, function (version, name) { try { self.maybeDownloadPackageForArchitectures({