sdfds
This commit is contained in:
@@ -22,19 +22,17 @@ class SeleniumBrowser {
|
||||
},
|
||||
destroy: (driver) => {
|
||||
logger.info('Quitting driver')
|
||||
return driver.quit()
|
||||
return driver.quit().then(() => {
|
||||
logger.debug({
|
||||
spare: this.pool.spareResourceCapacity,
|
||||
size: this.pool.size,
|
||||
available: this.pool.available,
|
||||
borrowed: this.pool.borrowed,
|
||||
pending: this.pool.pending
|
||||
}, 'Pool info')
|
||||
})
|
||||
},
|
||||
validate: (driver) => {
|
||||
logger.debug({
|
||||
spare: this.pool.spareResourceCapacity,
|
||||
size: this.pool.size,
|
||||
available: this.pool.available,
|
||||
borrowed: this.pool.borrowed,
|
||||
pending: this.pool.pending
|
||||
}, 'Pool info')
|
||||
if(this.pool.borrowed > 8) {
|
||||
this.pool.clear()
|
||||
}
|
||||
return driver.getSession().then(s => {
|
||||
logger.info('Driver session validation checked (id: %s)', s.getId())
|
||||
return true
|
||||
@@ -55,19 +53,6 @@ class SeleniumBrowser {
|
||||
this.pool.on('factoryDestroyError', function (err) {
|
||||
logger.error({ message: err.message }, 'pool error')
|
||||
})
|
||||
|
||||
// this.pool.use(driver => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// if (this.pool.available == 0) this.config.browserFullCount++
|
||||
// if (this.config.browserFullCount > 100) {
|
||||
// this.pool.clear()
|
||||
// this.config.browserFullCount = 0
|
||||
// reject(new Error('browser full count more than 100 times'))
|
||||
// } else {
|
||||
// resolve(driver)
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
}
|
||||
|
||||
getDriver() {
|
||||
@@ -92,7 +77,7 @@ class SeleniumBrowser {
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||
html = await htmlPromise
|
||||
this.pool.release(driver)
|
||||
this.pool.destroy(driver)
|
||||
return html
|
||||
})
|
||||
} else {
|
||||
@@ -163,10 +148,8 @@ class SeleniumBrowser {
|
||||
})
|
||||
}
|
||||
|
||||
async close() {
|
||||
this.pool.drain().then(function () {
|
||||
this.pool.clear();
|
||||
})
|
||||
close() {
|
||||
return this.pool.drain()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user