By default, the session file is locked upon each request, so a new request 
from the same client is blocked until the previous request is completed and 
the session file is unlocked (see 
here<http://web2py.com/books/default/chapter/29/04#session>). 
To avoid this problem, you can do one of the following:

   - In your app code, when a request for the Ajax function comes in, 
   immediately call session.forget(response).  This will unlock the session 
   file (and therefore prevent the session from being saved for that request). 
   You can include this line at the beginning of the Ajax function itself, or 
   you can include it earlier in a model file:

if request.function in [list, of, ajax, functions]:
    session.forget(response)

   - Store sessions in the database or in cookies, in which case there will 
   be no session files to be locked.
   - If you are not using the parameter-based rewrite system, you can use 
   the pattern-based rewrite system to disable automatic session connecting 
   for particular routes. In routes_in, instead of specifying a standard 
   2-tuple, you can specify a 3-tuple. The first two elements of the tuple are 
   as usual (incoming pattern and re-written pattern), and the third element 
   should be dict(web2py_disable_session=True). That will prevent the 
   framework from automatically connecting the session for that route (you can 
   still manually connect the session in your app code). In theory, this is a 
   little more efficient than the first option because it prevents the session 
   file from being locked at all (with the first option, the framework still 
   initially locks the session file, and then your app code unlocks it a bit 
   later).

Anthony

On Sunday, February 3, 2013 2:53:49 AM UTC-5, saransh wrote:
>
> Hello,
>
> I have a web-app that is running on host A, it runs a few commands on 
> another host B and i want to display the output of the commands running on 
> B on a webpage present on A i.e. i want to create a kind of live streaming 
> of B's console on a webpage present on A. 
>
> For this what i did is I redirected the output of B's console to a socket 
> on A and saved the output in a file on A. 
>
> I fire an ajax call that initiates the process(using web2py controller) to 
> start at B. This ajax call also handles the redirection of B's  console to 
> A's socket. 
>
> From the webpage I fire another ajax that reads the file in which the 
> data  of the socket is being stored. 
>
> Now the problem I am facing is that when I fire the secodn ajax call it 
> does not returns to the webpage untill the first ajax call is returned.
>
> I want to know that is this the correct way of doing this. Also i want to 
> know that, the problem I am facing is due to ajax or web2py framework?
>
> -Saransh
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to