Not able to handle serveral requests in parallel

34 views
Skip to first unread message

sonu kumar

unread,
Jul 24, 2015, 5:14:54 PM7/24/15
to web2py-users
Hi All,

I am facing issues with handling several request in parallel from same user.
When I submit one job and then simultaneously try to open my server homepage in new tab, it waits until first one finishes. I went through some earlier answers regarding this and came to know that there is some issue with session but I am not aware how to resolve this using session.forget() or where to put this in my code. I tried to put this in one function in my code but it doesn't allow my job to run further.

I have also used session variable in my views/html file...

I have attached my sample code...

Thanks
web2pycode.py

Anthony

unread,
Jul 24, 2015, 8:25:14 PM7/24/15
to web2py-users, sonu.bioi...@gmail.com, sonu.bioi...@gmail.com
If you have sessions in files, the session file is locked upon each request, so each new request must wait for the previous one to complete. This generally is much of a problem unless you have some very long running requests, as in your case. The best practice with long running operations is not to handle them in a single HTTP request but instead use the built-in scheduler or some kind of task queue to complete the task asynchronously. If you don't want to get into that complication right now, though, you can unlock the session file for a given request by doing:

session.forget(response)

Unfortunately, you can't use the above in your long-running uniprot_merops action, as that action writes to the session. That means you would instead have to unlock the session in any other actions you might want to view simultaneously (and of course, this won't help if some of those actions need to write to the session).

Also, as an aside, I see you "result" action simply calls the uniprot_merops action. I assume that means uniprot_merops is not attended to be reached on its own via URL. If that is the case, you should make it a private function by either giving it some arguments or preceding its name with a double underscore (in a controller, such functions are not reachable via URL).

Anthony
Reply all
Reply to author
Forward
0 new messages