[google-appengine] Re: GqlQuery bind method - is it safe to share the same query instance between requests?

2008-12-20 Thread djidjadji

Be aware that the value of a global variable is not known at the start
of a request.
It could be the value from the previous request if the interpreter was
already warm/running.
It would be the initial value if the interpreter was started cold.

Why not put the GQL object in the request handler self.gql1=
GqlQuery(...) or just a local variable?
How often do you bind new values to the query for each request?

2008/12/17 Alex Epshteyn alexander.epsht...@gmail.com:

 Ah, I see.  It's safe because a new request will not be processed by
 the same instance of the python interpreter until the previous request
 has fully completed, right?

 Thanks, Ryan!

 On Dec 16, 7:37 pm, Ryan Barrett goo...@ryanb.org wrote:
 hi alex! you're right to be cautious, but happily, requests are not
 handled by different threads. our python interpreters are single
 threaded, and handle only a single request at a time. more:

 http://code.google.com/appengine/docs/python/sandbox.htmlhttp://groups.google.com/group/google-appengine/browse_thread/thread/...

 given that, you don't need to worry about concurrent accesses to the
 query global variable, so this should be safe. even better, fetch() re-
 runs the query from the beginning, so if the parameters are the same
 across requests, you don't even need to bind() each time.
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: GqlQuery bind method - is it safe to share the same query instance between requests?

2008-12-20 Thread Dan Sanderson
The advantage of caching GqlQuery objects between requests is that it saves
on having to compile the GQL for future requests.  By storing it in a global
and binding new values prior to calling, it gets compiled on the first
request for the web server instance, and uses the pre-compiled version on
subsequent requests.
The only caveat is that you must remember to bind values prior to executing
the query (calling fetch(), get() or using the iterator interface).  If you
call without binding, it might use values bound during a previous request.

-- Dan

On Sat, Dec 20, 2008 at 3:25 AM, djidjadji djidja...@gmail.com wrote:


 Be aware that the value of a global variable is not known at the start
 of a request.
 It could be the value from the previous request if the interpreter was
 already warm/running.
 It would be the initial value if the interpreter was started cold.

 Why not put the GQL object in the request handler self.gql1=
 GqlQuery(...) or just a local variable?
 How often do you bind new values to the query for each request?

 2008/12/17 Alex Epshteyn alexander.epsht...@gmail.com:
 
  Ah, I see.  It's safe because a new request will not be processed by
  the same instance of the python interpreter until the previous request
  has fully completed, right?
 
  Thanks, Ryan!
 
  On Dec 16, 7:37 pm, Ryan Barrett goo...@ryanb.org wrote:
  hi alex! you're right to be cautious, but happily, requests are not
  handled by different threads. our python interpreters are single
  threaded, and handle only a single request at a time. more:
 
 
 http://code.google.com/appengine/docs/python/sandbox.htmlhttp://groups.google.com/group/google-appengine/browse_thread/thread/.
 ..
 
  given that, you don't need to worry about concurrent accesses to the
  query global variable, so this should be safe. even better, fetch() re-
  runs the query from the beginning, so if the parameters are the same
  across requests, you don't even need to bind() each time.
  
 

 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: GqlQuery bind method - is it safe to share the same query instance between requests?

2008-12-16 Thread Ryan Barrett

hi alex! you're right to be cautious, but happily, requests are not
handled by different threads. our python interpreters are single
threaded, and handle only a single request at a time. more:

http://code.google.com/appengine/docs/python/sandbox.html
http://groups.google.com/group/google-appengine/browse_thread/thread/3f8cfeaf7dc2eb72/7a5918d69158ae1b?#7a5918d69158ae1b

given that, you don't need to worry about concurrent accesses to the
query global variable, so this should be safe. even better, fetch() re-
runs the query from the beginning, so if the parameters are the same
across requests, you don't even need to bind() each time.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---



[google-appengine] Re: GqlQuery bind method - is it safe to share the same query instance between requests?

2008-12-16 Thread Alex Epshteyn

Ah, I see.  It's safe because a new request will not be processed by
the same instance of the python interpreter until the previous request
has fully completed, right?

Thanks, Ryan!

On Dec 16, 7:37 pm, Ryan Barrett goo...@ryanb.org wrote:
 hi alex! you're right to be cautious, but happily, requests are not
 handled by different threads. our python interpreters are single
 threaded, and handle only a single request at a time. more:

 http://code.google.com/appengine/docs/python/sandbox.htmlhttp://groups.google.com/group/google-appengine/browse_thread/thread/...

 given that, you don't need to worry about concurrent accesses to the
 query global variable, so this should be safe. even better, fetch() re-
 runs the query from the beginning, so if the parameters are the same
 across requests, you don't even need to bind() each time.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Google App Engine group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---