我正在处理一个pelias项目,并使用wof-admin-lookup包来处理从文件读取的数据。
有一种情况,没有有效的数据可以推送到流中。wof-admin-lookup永远不会结束。
下面是我的代码:
const stream = recordStream.create(filePath)
.pipe(blacklistStream())
.pipe(adminLookup.create())
.pipe(model.createDocumentMapperStream())
.pipe(peliasDbclient())
stream
.on('data', data => {
count++
})
.on('finish', () => {
console.log(`Imported ${count} addresses`)
resolve()
})
.on('error', (e) => {
reject(e)
})下面是wof-admin-lookup中的代码:
module.exports = function(pipResolver, config) {
if (!pipResolver) {
throw new Error('valid pipResolver required to be passed in as the first parameter');
}
// pelias 'imports.adminLookup' config section
config = config || {};
const pipResolverStream = createPipResolverStream(pipResolver, config);
const end = createPipResolverEnd(pipResolver);
const stream = parallelTransform(config.maxConcurrentReqs || 1, pipResolverStream);
stream.on('end', end);
return stream;
};虽然控制台记录了“导入的0个地址”,但如果我不通过Ctrl+C手动关闭它,pipResolverStream将永远保留。
更新时,只有在没有数据通过流传递时才会发生这种情况。
发布于 2021-09-16 04:29:56
“如果没有像< /dev/null这样的东西来生成EOF,则end事件永远不会触发。否则程序将等待终端发送^D。”
https://stackoverflow.com/questions/69201659
复制相似问题