[web2py] Re: Understanding Rocket Threads

2011-08-26 Thread Ray (a.k.a. Iceberg)
Thank you Anthony, I knew session.forget() but did not know it would
be so helpful for performance. I'll try that in my projects from now
on.

Regards,
Ray

On Aug 26, 2:42 am, Anthony abasta...@gmail.com wrote:
 If you don't explicitly forget the session, the session file will lock on
 each request, so subsequent requests will be blocked. Maybe you could forget
 the session on requests that don't need it and just keep it for requests
 that do need it (i.e., form submissions).

 Note, to immediately unlock the session file, you need to do
 session.forget(response), not just session.forget().

 Anthony







 On Thursday, August 25, 2011 2:14:54 PM UTC-4, G wrote:

  I tried session.forget() but found that forms submitted by ajax in
  components don't seem to work without a session, so that won't work in
  my case.

  I also tried removing the SQLite db, it may have helped some but I'm
  still testing.

  Thanks again for the suggestions

  On Aug 24, 4:18 pm, Michele Comitini michele@gmail.com
  wrote:
   Try session.forget() and see what happens

   mic

   2011/8/25 G glenn@gmail.com:

Thank you for the suggestion. I made a test application that used no
database accesses (no auth and randomly generated data). It showed the
same behavior, so I do not think it is the culprit. In addition, since
the application is monitor only, the real application only reads from
the database, which I hope would not impose a transaction lock.

G

On Aug 24, 3:20 pm, ron_m ron.m...@gmail.com wrote:
You also need to consider the database type used by the application
  for the
model. The SQLite database has a transaction lock which will cause the

application to look like it is single threaded if the database is held
  in a
transaction pending state while the background work is performed.


[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread Ray (a.k.a. Iceberg)
Hi G,

I saw similar behaviors in some of my lightweight app, which also uses
sqlite and rocket. I need not solve that problem at that time (it was
really a little app for a small group). But I can provide some
information to you this time.

When you try to isolate the sqlite, using no auth and randomly
generating data are not enough. You would better completely take out
this line:

db = DAL('sqlite://storage.sqlite')

that means completely avoid db definition and db opening. That is
because, in web2py, even a sqlite db open attempt will open the db in
exclusive mode, hence blocking other requests to the same app. (That
was true, I don't know whether that was changed since then. Massimo
can confirm that.)

Regards,
Ray

On Aug 25, 6:37 am, G glenn.calt...@gmail.com wrote:
 Thank you for the suggestion. I made a test application that used no
 database accesses (no auth and randomly generated data). It showed the
 same behavior, so I do not think it is the culprit. In addition, since
 the application is monitor only, the real application only reads from
 the database, which I hope would not impose a transaction lock.

 G

 On Aug 24, 3:20 pm, ron_m ron.mco...@gmail.com wrote:

  You also need to consider the database type used by the application for the
  model. The SQLite database has a transaction lock which will cause the
  application to look like it is single threaded if the database is held in a
  transaction pending state while the background work is performed.


[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread G
I tried session.forget() but found that forms submitted by ajax in
components don't seem to work without a session, so that won't work in
my case.

I also tried removing the SQLite db, it may have helped some but I'm
still testing.

Thanks again for the suggestions

On Aug 24, 4:18 pm, Michele Comitini michele.comit...@gmail.com
wrote:
 Try session.forget() and see what happens

 mic

 2011/8/25 G glenn.calt...@gmail.com:

  Thank you for the suggestion. I made a test application that used no
  database accesses (no auth and randomly generated data). It showed the
  same behavior, so I do not think it is the culprit. In addition, since
  the application is monitor only, the real application only reads from
  the database, which I hope would not impose a transaction lock.

  G

  On Aug 24, 3:20 pm, ron_m ron.mco...@gmail.com wrote:
  You also need to consider the database type used by the application for the
  model. The SQLite database has a transaction lock which will cause the
  application to look like it is single threaded if the database is held in a
  transaction pending state while the background work is performed.




[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread Anthony
If you don't explicitly forget the session, the session file will lock on 
each request, so subsequent requests will be blocked. Maybe you could forget 
the session on requests that don't need it and just keep it for requests 
that do need it (i.e., form submissions).

Note, to immediately unlock the session file, you need to do 
session.forget(response), not just session.forget().

Anthony

On Thursday, August 25, 2011 2:14:54 PM UTC-4, G wrote:

 I tried session.forget() but found that forms submitted by ajax in 
 components don't seem to work without a session, so that won't work in 
 my case. 

 I also tried removing the SQLite db, it may have helped some but I'm 
 still testing. 

 Thanks again for the suggestions 

 On Aug 24, 4:18 pm, Michele Comitini michele@gmail.com 
 wrote: 
  Try session.forget() and see what happens 
  
  mic 
  
  2011/8/25 G glenn@gmail.com: 
  
   Thank you for the suggestion. I made a test application that used no 
   database accesses (no auth and randomly generated data). It showed the 
   same behavior, so I do not think it is the culprit. In addition, since 
   the application is monitor only, the real application only reads from 
   the database, which I hope would not impose a transaction lock. 
  
   G 
  
   On Aug 24, 3:20 pm, ron_m ron.m...@gmail.com wrote: 
   You also need to consider the database type used by the application 
 for the 
   model. The SQLite database has a transaction lock which will cause the 

   application to look like it is single threaded if the database is held 
 in a 
   transaction pending state while the background work is performed. 
  
 



[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread G
Hi,
Can you explain this a bit more? Is the idea to call
session.forget(response) in my main controller, but not in the
components that have forms in them? I had previously put the
session.forget() line in the model file so it was always executed.
Thanks

On Aug 25, 11:42 am, Anthony abasta...@gmail.com wrote:
 If you don't explicitly forget the session, the session file will lock on
 each request, so subsequent requests will be blocked. Maybe you could forget
 the session on requests that don't need it and just keep it for requests
 that do need it (i.e., form submissions).

 Note, to immediately unlock the session file, you need to do
 session.forget(response), not just session.forget().

 Anthony

 On Thursday, August 25, 2011 2:14:54 PM UTC-4, G wrote:

  I tried session.forget() but found that forms submitted by ajax in
  components don't seem to work without a session, so that won't work in
  my case.

  I also tried removing the SQLite db, it may have helped some but I'm
  still testing.

  Thanks again for the suggestions

  On Aug 24, 4:18 pm, Michele Comitini michele@gmail.com
  wrote:
   Try session.forget() and see what happens

   mic

   2011/8/25 G glenn@gmail.com:

Thank you for the suggestion. I made a test application that used no
database accesses (no auth and randomly generated data). It showed the
same behavior, so I do not think it is the culprit. In addition, since
the application is monitor only, the real application only reads from
the database, which I hope would not impose a transaction lock.

G

On Aug 24, 3:20 pm, ron_m ron.m...@gmail.com wrote:
You also need to consider the database type used by the application
  for the
model. The SQLite database has a transaction lock which will cause the

application to look like it is single threaded if the database is held
  in a
transaction pending state while the background work is performed.




[web2py] Re: Understanding Rocket Threads

2011-08-25 Thread Anthony
On Thursday, August 25, 2011 3:28:38 PM UTC-4, G wrote:

 Hi, 
 Can you explain this a bit more? Is the idea to call 
 session.forget(response) in my main controller, but not in the 
 components that have forms in them? I had previously put the 
 session.forget() line in the model file so it was always executed.


Yes, you can put session.forget(response) anywhere (model, controller 
outside a function, controller inside a function). If you put it in a model 
file, you could make it conditional:

session_actions = ['component_with_form1','component_with_form2',...]
if not request.function in session_actions:
session.forget(response)


Anthony 


[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread G
I should also mention I'm open to other suggestions to alleviate this
problem. The end goal is to display information (text or image) then
request an update, and when it's ready, display the new text/
information.

G

On Aug 24, 11:39 am, G glenn.calt...@gmail.com wrote:
 Hi,
 First a little background: My application involves displaying and auto-
 refreshing data both in the form of text from .load components and
 dynamically generated images. I use JavaScript setInterval calls so
 that ideally the refreshes should occur some time after the last
 refresh completes. As it turns out, this does not work for the images
 because using jQuery to update the .attr with the new img src returns
 immediately, not after the image is loaded.
 Anyway, the amount of time required to generate these images and text
 data can be somewhat random, so I'm finding that my site will work for
 a while, but eventually the long duration requests will pile up and
 the site becomes unresponsive. Interestingly, the admin interface is
 still as responsive as usual. I also notice that killing web2py will
 not cause a clean exit, there will still be a thread working furiously
 on the queued requests.

 Thus it looks like rocket is using only one thread for the requests on
 the main page, while the other threads sit idle and ready to service
 other pages e.g. the admin interface. I tried to look through the code
 of rocket.py to decide if this is indeed the case, but I wasn't able
 to conclude one way or another. Since the admin interface is still
 responsive, this does not appear to be an issue of the global
 interpreter lock.

 I found that starting many web2py servers on different ports, and then
 directing the refresh calls to use a dedicated server for each data
 source alleviated the problem somewhat, further suggesting to me that
 only one thread is being used per session/browser/whatever to call it.

 I expect to have no more than 2 users at a time for my application, so
 I was hoping Rocket would be sufficient for this application. Would I
 have better luck with apache or the like? I appreciate any advice on
 the matter.

 The code I'm using in the view to refresh the data is listed below

 Thank you for the help,
 G

 View: --- default/index.html
 

 div id=test3{{=LOAD('default','calc3.load')}}/div
 img id=test2 src={{=URL('default','calc2.png')}}/img
 img id=test1 src={{=URL('default','calc1.png')}}/img
 script
 jQuery(window).load(function()
 {setCalc1Timeout();setCalc2Timeout();setCalc3Timeout()});

 function updateCalc3() {

 jQuery('#test3').load('{{=URL(default,calc3.load)}}',setCalc3Timeout);
     }
 function setCalc3Timeout() {
     setTimeout(updateCalc3, 2000);
     }

 function setCalc2Timeout() {
         setTimeout(updateCalc2,5000);
     }
 function updateCalc2() {
         d = new Date();
         jQuery('#test2').attr('src',calc2.png+?+d.getTime());
         setCalc2Timeout();
     }

 function setCalc1Timeout() {
         setTimeout(updateCalc1,5000);
     }
 function updateCalc1() {
         d = new Date();
         jQuery('#test1').attr('src',calc1.png+?+d.getTime());
         setCalc1Timeout();
     }
 /script


[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread ron_m
You also need to consider the database type used by the application for the 
model. The SQLite database has a transaction lock which will cause the 
application to look like it is single threaded if the database is held in a 
transaction pending state while the background work is performed.


[web2py] Re: Understanding Rocket Threads

2011-08-24 Thread G
Thank you for the suggestion. I made a test application that used no
database accesses (no auth and randomly generated data). It showed the
same behavior, so I do not think it is the culprit. In addition, since
the application is monitor only, the real application only reads from
the database, which I hope would not impose a transaction lock.

G

On Aug 24, 3:20 pm, ron_m ron.mco...@gmail.com wrote:
 You also need to consider the database type used by the application for the
 model. The SQLite database has a transaction lock which will cause the
 application to look like it is single threaded if the database is held in a
 transaction pending state while the background work is performed.


Re: [web2py] Re: Understanding Rocket Threads

2011-08-24 Thread Michele Comitini
Try session.forget() and see what happens

mic


2011/8/25 G glenn.calt...@gmail.com:
 Thank you for the suggestion. I made a test application that used no
 database accesses (no auth and randomly generated data). It showed the
 same behavior, so I do not think it is the culprit. In addition, since
 the application is monitor only, the real application only reads from
 the database, which I hope would not impose a transaction lock.

 G

 On Aug 24, 3:20 pm, ron_m ron.mco...@gmail.com wrote:
 You also need to consider the database type used by the application for the
 model. The SQLite database has a transaction lock which will cause the
 application to look like it is single threaded if the database is held in a
 transaction pending state while the background work is performed.