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

Commit

Permalink
temporary debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff.thorpe committed Apr 20, 2023
1 parent 51fbb92 commit ab1fcd8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/run-parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,40 @@ const { Sema } = require('async-sema');
const EventedQueue = require('./evented-queue');

module.exports = (tasks = [], concurrency = 1, preserveOrder = false) => {
console.log('@@@@@@@@@ RUN PARALLEL @@@@@@@@@@');
const semaphore = new Sema(concurrency);
console.log('@@@@@@@@@ semaphore @@@@@@@@@@');
console.log(semaphore);
const queue = new EventedQueue();
console.log('@@@@@@@@@ queue @@@@@@@@@@');
console.log(queue);

return Promise.all(
tasks.map(async ({ pkg, apply }) => {
console.log(`@@@@@@@@@@@@@@@ START ${pkg.name} @@@@@@@@@@@@@@@@@@`);
queue.add(pkg.name);

console.log('@@@@@@@@@@ before acquire @@@@@@@@@@');
await semaphore.acquire();
console.log('@@@@@@@@@@ after acquire @@@@@@@@@@');

// wait for any dependencies still in the queue to finish
if (preserveOrder) {
console.log(
'@@@@@@@@@@@@@@@@@@ waiting for dependency @@@@@@@@@@@@@@@@@',
);
console.log(pkg.allDependencies);
await queue.waitBehind(pkg.allDependencies);
}

console.log('@@@@@@@@@@ before apply @@@@@@@@@@');
await apply();
console.log('@@@@@@@@@@ after apply @@@@@@@@@@');

queue.delete(pkg.name);

semaphore.release();
console.log(`@@@@@@@@@@@@@@@ END ${pkg.name} @@@@@@@@@@@@@@@@@@`);
}),
);
};

0 comments on commit ab1fcd8

Please sign in to comment.