var mysql = require('mysql');
var pool = mysql.createPool(...);
pool.getConnection(function(err, connection) {
// Use the connection
connection.query('SELECT something FROM sometable', function (error, results, fields) {
// And done with the connection.
connection.release();
// Handle error after the release.
if (error) throw error;
// Don't use the connection here, it has been returned to the pool.
});
});
可以尝试process.exit手动退出。。。
@fruit-memory 除了这么暴力的做法,还有其他嘛?
goon什么情况下为fasle
来自酷炫的 CNodeMD
还没细看看你的代码,不过写爬虫,应该用mongo连接池的,用完一个连接释放就可以了,你这样每请求一个获取一个连接然后在断开一个连接性能太差,时间都浪费在建立连接上了
@jjeejj 难道不用关吗? 连接池该如何改?
@zswnew 一次抓完 600 页后。
@JZLeung mysql 模块中有个
mysql.createPool方法比如:
具体的你可以查看文档的 mysql
process.exit()@jjeejj mongodb.
@wxs77577 超时了,因为我有 await。