Skip to content

Commit

Permalink
benchmark: Delay shutdown in quitWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Jul 31, 2023
1 parent 90adc8a commit 1f08883
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/performance/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,20 @@ function main() {
});
serverWorkerStream.on('status', (status) => {
console.log('Received server worker status ' + JSON.stringify(status));
clientWorker.quitWorker({}, (error, response) => {
if (error) {
console.log('Received error on clientWorker.quitWorker:', error);
} else {
console.log('Received response from clientWorker.quitWorker');
}
});
serverWorker.quitWorker({}, (error, response) => {
if (error) {
console.log('Received error on serverWorker.quitWorker:', error);
} else {
console.log('Received response from serverWorker.quitWorker');
}
});
});
}

Expand Down
7 changes: 6 additions & 1 deletion test/performance/worker_service_impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ module.exports = function WorkerServiceImpl(benchmark_impl, server) {

this.quitWorker = function quitWorker(call, callback) {
callback(null, {});
server.tryShutdown(function() {});
/* Due to https://github.com/nodejs/node/issues/42713, tryShutdown acts
* like forceShutdown on some Node versions. So, delay calling tryShutdown
* until after done handling this request. */
setTimeout(() => {
server.tryShutdown(function() {});
}, 10);
};

this.runClient = function runClient(call) {
Expand Down

0 comments on commit 1f08883

Please sign in to comment.