1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Prevent attempt to gracefull kill device worker during cleanup if it has already exited. Not very elegant but it does its job. This should get rid of most Ctrl+C delays.

This commit is contained in:
Simo Kinnunen 2017-02-10 01:31:16 +09:00
parent 083a2a1f92
commit 86ed8cd1f0

View file

@ -181,8 +181,10 @@ module.exports = function(options) {
var allocatedPorts = ports.splice(0, 4)
var proc = options.fork(device, allocatedPorts.slice())
var resolver = Promise.defer()
var didExit = false
function exitListener(code, signal) {
didExit = true
if (signal) {
log.warn(
'Device worker "%s" was killed with signal %s, assuming ' +
@ -248,8 +250,10 @@ module.exports = function(options) {
_.pull(lists.waiting, device.id)
})
.catch(Promise.CancellationError, function() {
log.info('Gracefully killing device worker "%s"', device.id)
return procutil.gracefullyKill(proc, options.killTimeout)
if (!didExit) {
log.info('Gracefully killing device worker "%s"', device.id)
return procutil.gracefullyKill(proc, options.killTimeout)
}
})
.catch(Promise.TimeoutError, function(err) {
log.error(