Hello
I'am trying to build application on GAE which use MongoDB hosted at
Mongolab provider.
Connection work, if I made new connection every request, but if I want to
reuse once established connection, GAE freeze and die on timeout.
I believe that exist some simple way, how to do that such simple task.
----- This is woring, but open new connection every request: ------
def get_database_connection():
client = pymongo.MongoClient(MONGO_URI)
DBCONN = client.get_default_database()
return DBCONN
DBCON = get_database_connection()
... do something usefull with DBCONN ...
... not store connection anywhere ....
... end request ....
---- This freeze GAE and die on timeout ---
def get_database_connection():
if "DBCONN" in globals(): # look for open connection in
instance memory
return globals()["DBCONN"]
client = pymongo.MongoClient(MONGO_URI)
DBCONN = client.get_default_database()
globals()["DBCONN"] = DBCONN # store connection to instance memory
return DBCONN
DBCONN = get_database_connection()
... do something usefull with DBCONN ...
... end request ....
--------
Probably GAE module with backend thread can be uset to keep connection open
in separate thread, but after many hours I can“t find working solution.
Hope somebody can experience with this usecase and can help me. Also link
to well-tried solution will be helpfull.
Have a nice day.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/33df8ac3-d561-4726-8fbe-89bcaf14a9e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.