Forums

not able to use asynchronous requests

I am using AJAX for running a task which is updating database in bulk and taking time to execute. I want to be able to return back to user and allow him to check the database as it is getting updated. I have done this by calling the database update task as AJAX request and then calling another view to display the results. The issue is the task waits for the database update to finish before allowing the other view to be uploaded. I tried even without using database results in the other view but still it waits for the update task before moving to the other view. Can you suggest what to do? I searched on the forums and one of the issues that came up was the lack of threading in pythonanywhere. Do you think its because of that issue? Or is it some database issue, I am using mysql ( it does not look like the case because even when I am trying to display an empty view it waits). Am I missing something?

This sounds like it's because you have a free account. Free accounts get only one WSGI worker process. For simple sites, where only one request needs to be processed at a time, and requests are handled quickly, that's enough. But if you want to handle requests in parallel, you need more workers.

Try upgrading to a paid plan -- you can specify the number of worker processes you want during the upgrade process. Two should be enough to test your system as you describe it, though of course you would need more if lots of people might be doing these bulk updates at the same time.