简体   繁体   English

Django - 异步使用RESTful服务

[英]Django - Consuming a RESTful service asynchronously

I need to create a django web portal in which users can select and run ad-hoc reports by providing values, via forms, to parameters defined in each specific report. 我需要创建一个django Web门户,用户可以通过在每个特定报告中定义的参数通过表单提供值来选择和运行临时报告。 The view that processes the user's report execution requests needs to make RESTFul service calls to a remote Jasper Reports Server where the actual output is generated. 处理用户报告执行请求的视图需要对生成实际输出的远程Jasper Reports Server进行RESTFul服务调用。

I have already written the client to make the RESTful service calls to the remote server. 我已经编写了客户端来对远程服务器进行RESTful服务调用。 Depending on how large the report is the service calls can take several minutes. 根据报告的大小,服务调用可能需要几分钟。

What is the best method for making the service call after the user's form has been validated so that the call processes asynchronously (in the background) and the user can continue you use the web portal while their report is being generated. 在验证用户表单之后进行服务调用的最佳方法是什么,以便调用异步(在后台)进行调用,并且用户可以在生成报表时继续使用Web门户。

Do I need to make an AJAX call when the parameters form is submitted or should I start a new thread for the RESTful client in the view after the form has validated? 我是否需要在提交参数表单时进行AJAX调用,或者在表单验证后是否应该在视图中为RESTful客户端启动新线程? Or something else? 或者是其他东西?

django-celery is a popular choice for async tasks, i usually use greenlets as im used to them. django-celery是异步任务的流行选择,我通常使用greenlets作为他们习惯的。

Then to notify the user you can use the notification framework to tell the client that something is done. 然后,为了通知用户,您可以使用通知框架告诉客户端已完成某项操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM