Django 中的异步数据库更新?
我的网站上有一个大表格。当用户填写并提交时,大部分数据都会转储到数据库,然后重定向到新页面。但是,我还想使用这些数据来查询另一个站点,然后解析结果。这可能需要更长的时间。用户不一定要立即看到这些结果,所以我想知道是否可以异步调用一个函数来处理这个问题,然后像往常一样从我的视图中返回 HttpResponse 而不让他们等待?
如果是这样...怎么办?我应该查看哪些特定的库?
I have a big form on my site. When the users fill it out and submit it, most of the data just gets dumped to the database, and then they get redirected to a new page. However, I'd also like to use the data to query another site, and then parse the results. That might take a bit longer. It's not essential that the user sees these results right away, so I was wondering if it's possible to asynchronously call a function that will handle this, and then return an HttpResponse from my view like usual without making them wait?
If so... how? Any particular libraries I should look at?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用户 RabbitMQ 和 芹菜与django。如果您部署在 EC2 上,还请查看 SQS
您从请求-响应周期创建消息并且替代进程或 cron 会不断检查消息。
User RabbitMQ and Celery with django. If you are deployed on EC2, also look at SQS
You create a message from the request-response cycle and an alternative process or a cron keeps checking off the messages.