mirror of
https://github.com/openstf/stf
synced 2025-10-04 02:09:32 +02:00
Hopefully get rid of FrameProducer._stop() timeouts. Doesn't reproduce locally.
This commit is contained in:
parent
cfc84a0e42
commit
dc07777829
3 changed files with 52 additions and 42 deletions
|
@ -325,39 +325,32 @@ module.exports = syrup.serial()
|
|||
|
||||
var pid = this.banner ? this.banner.pid : -1
|
||||
|
||||
function waitForEnd() {
|
||||
var endListener
|
||||
return new Promise(function(resolve/*, reject*/) {
|
||||
output.expectEnd().on('end', endListener = function() {
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
.finally(function() {
|
||||
output.removeListener('end', endListener)
|
||||
})
|
||||
}
|
||||
|
||||
function kill(signal) {
|
||||
if (pid <= 0) {
|
||||
return Promise.reject(new Error('Minicap service pid is unknown'))
|
||||
}
|
||||
|
||||
log.info('Sending SIGTERM to minicap')
|
||||
var signum = {
|
||||
'SIGTERM': -15
|
||||
, 'SIGKILL': -9
|
||||
}[signal]
|
||||
|
||||
log.info('Sending %s to minicap', signal)
|
||||
return Promise.all([
|
||||
waitForEnd()
|
||||
, adb.shell(options.serial, ['kill', signal, pid])
|
||||
output.waitForEnd()
|
||||
, adb.shell(options.serial, ['kill', signum, pid])
|
||||
.then(adbkit.util.readAll)
|
||||
.timeout(2000)
|
||||
.return(true)
|
||||
])
|
||||
.timeout(2000)
|
||||
}
|
||||
|
||||
function kindKill() {
|
||||
return kill('-15')
|
||||
return kill('SIGTERM')
|
||||
}
|
||||
|
||||
function forceKill() {
|
||||
return kill('-9')
|
||||
return kill('SIGKILL')
|
||||
}
|
||||
|
||||
function forceEnd() {
|
||||
|
|
|
@ -337,39 +337,32 @@ module.exports = syrup.serial()
|
|||
|
||||
var pid = this.banner ? this.banner.pid : -1
|
||||
|
||||
function waitForEnd() {
|
||||
var endListener
|
||||
return new Promise(function(resolve/*, reject*/) {
|
||||
output.expectEnd().on('end', endListener = function() {
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
.finally(function() {
|
||||
output.removeListener('end', endListener)
|
||||
})
|
||||
}
|
||||
|
||||
function kill(signal) {
|
||||
if (pid <= 0) {
|
||||
return Promise.reject(new Error('Minitouch service pid is unknown'))
|
||||
}
|
||||
|
||||
log.info('Sending SIGTERM to minitouch')
|
||||
var signum = {
|
||||
'SIGTERM': -15
|
||||
, 'SIGKILL': -9
|
||||
}[signal]
|
||||
|
||||
log.info('Sending %s to minitouch', signal)
|
||||
return Promise.all([
|
||||
waitForEnd()
|
||||
, adb.shell(options.serial, ['kill', signal, pid])
|
||||
output.waitForEnd()
|
||||
, adb.shell(options.serial, ['kill', signum, pid])
|
||||
.then(adbkit.util.readAll)
|
||||
.timeout(2000)
|
||||
.return(true)
|
||||
])
|
||||
.timeout(2000)
|
||||
}
|
||||
|
||||
function kindKill() {
|
||||
return kill('-15')
|
||||
return kill('SIGTERM')
|
||||
}
|
||||
|
||||
function forceKill() {
|
||||
return kill('-9')
|
||||
return kill('SIGKILL')
|
||||
}
|
||||
|
||||
function forceEnd() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var util = require('util')
|
||||
|
||||
var Promise = require('bluebird')
|
||||
var EventEmitter = require('eventemitter3').EventEmitter
|
||||
|
||||
function RiskyStream(stream) {
|
||||
|
@ -34,4 +35,27 @@ RiskyStream.prototype.expectEnd = function() {
|
|||
return this
|
||||
}
|
||||
|
||||
RiskyStream.prototype.waitForEnd = function() {
|
||||
var stream = this.stream
|
||||
, endListener
|
||||
|
||||
this.expectEnd()
|
||||
|
||||
return new Promise(function(resolve/*, reject*/) {
|
||||
if (stream.ended) {
|
||||
return resolve(true)
|
||||
}
|
||||
|
||||
stream.on('end', endListener = function() {
|
||||
resolve(true)
|
||||
})
|
||||
|
||||
// Make sure we actually have a chance to get the 'end' event.
|
||||
stream.resume()
|
||||
})
|
||||
.finally(function() {
|
||||
stream.removeListener('end', endListener)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = RiskyStream
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue