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