微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何将大量数据从 node.js 应用程序发送到 python 文件?

如何解决如何将大量数据从 node.js 应用程序发送到 python 文件?

我有一个包含 2 个(或更多)嵌套对象的 json 对象,每个对象中有 18 个键值对,基本上 json 对象是一个存储文章的对象,每个嵌套对象都包含此类信息。

>
{
createdAt: date,lastUpdated: date,content: of 250 words,...
.
.
.
.
.
.

and many more fields
}

现在我想将此对象发送到某个机器学习应用程序的 python 文件,并且我已经使用 spawn 模块完成了它,我通过以下命令发送此数据:

const childPython = spawn('python',['hello.py',JSON.stringify(posts)])

但它显示了这个错误

(node:21728) UnhandledPromiseRejectionWarning: Error: spawn ENAMetoOLONG
    at ChildProcess.spawn (internal/child_process.js:403:11)
    at spawn (child_process.js:553:9)
    at Object.showObj.getSimilararticles (D:\done\VSCode\learners backend v2\controllers\showPageController.js:92:27)
    at processticksAndRejections (internal/process/task_queues.js:93:5)
    at async D:\done\VSCode\learners backend v2\routes\posts.js:1519:3
(Use `node --trace-warnings ...` to show where the warning was created)
(node:21728) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block,or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection,use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:21728) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future,promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

现在我的问题是因为尺寸大,如果是的话,还有其他可能的解决方案来传达数据吗? 如果不是,我做错了什么,我该如何纠正?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。