1, you can't.  you can expose an URL and view for your client-side app to 
request for task state.  if response of state is "SUCCESS", then you can 
trigger a client side redirect.
2. when using celery, pass in only the data it's needed, such as a db 
record ID, and do all your retrievals inside the task.

Some reading for celery best practices:

https://denibertovic.com/posts/celery-best-practices/
https://blog.balthazar-rouberol.com/celery-best-practices
https://khashtamov.com/en/celery-best-practices-practical-approach/

On Monday, June 11, 2018 at 9:14:42 AM UTC-4, Mohammed Noor wrote:
>
> Hello guys,
>
> I need to create  a django application that takes a repository url, builds 
> the code located in the url location and runs a few tests. If the tests are 
> successfull, it tags the code and then sends an email to the user notifying 
> the same. 
>
> Because the building process takes a long time, I have used celery to run 
> it as a background process. I am implementing the following design.
>
> def main_function(request):
>           # lines_of_code
>           result=tasks.BuildCodeAndVerify.delay(args)
>           #few more lines of code
>           return (request,'waiting_page.html',context)
>
> Note: The waiting page has a progress bar that reads percentage progress 
> from my celery task i.e BuildCodeAndVerify. 
>
> *Now, I am facing two problems:*
>
> 1. If the build is successful, i need to redirect from the waiting page 
> and update the html view with a success page and a summary of the build. 
> How do i make the celery task redirect a webpage? Also, it needs to pass 
> a dictionary to the webpage containing a summary. How do i do all this?
>
> 2. Is it possible to pass the request object as an argument like  
> BuildCodeAndVerify(request,other_args). Because whenever I try i get an 
> error saying. "WSGI error: type object is not JSON serializable." 
>
>
> And I have very limited django and python knowledge so please go easy on 
> me if my questions look naive. 
>
> Would be grateful for any help and advice i can get.
>
> Thanks a lot!
> Khasim
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2c43e673-d203-4a78-882f-1723c9c9bd0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to