My understanding is that pymongo has connection pooling builtin. ->
http://api.mongodb.org/python/current/api/pymongo/connection.html

Also, it appears that an addition to the cache method described by
Massimo enables the use replica sets as well.
You still need to handle AutoReconnect exceptions when the master is
lost. -> 
http://api.mongodb.org/python/current/api/pymongo/errors.html#pymongo.errors.AutoReconnect

def make_connection():
    from pymongo import Connection
    connection = Connection('localhost', 27017, replicaset="setName")
    return connection

connection = cache.ram('mongodb',make_connection,None)

Regards,
Daniel


On Aug 14, 11:25 am, Karthik <karthikparameswa...@gmail.com> wrote:
> I'm still looking for a solution to simulate connection pooling, any
> responses would be great - thanks!
>
> On Jul 21, 4:53 pm, Karthik <karthikparameswa...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi Massimo,
>
> > Thanks for this. Do you know if it will hold up in a high performance
> > situation though?
> > As in, if multiple connections originate at the same time, won't there
> > be a queue?
> > Is it possible to simulate the connection pooling mechanism in
> > web2py's DAL?
>
> > Thanks,Karthik
>
> > On Jul 31 2010, 4:13 am, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > how about this? (None below means cache forever)
>
> > > def make_connection():
> > >     frompymongoimport Connection
> > >     connection = Connection('localhost', 27017)
> > >     return connection
>
> > > connection = cache.ram('mongodb',make_connection,None)
>
> > > On Jul 31, 3:11 am, David Marko <dma...@tiscali.cz> wrote:
>
> > > > Hi Massimo, can you give ua a hint how to impelement persistent
> > > > connection in web2py forpyMongo?PyMongorequires database connection
> > > > and to use it efficiently the connection has to be persistent and
> > > > shared among requests like a connection pool for database connections
> > > > as DAL has. But how to do it in web2py?
>
> > > > e.g.
> > > > frompymongoimport Connection
> > > > connection = Connection('localhost', 27017)
>
> > > > ### how to keep this connection object?
>
> > > > David
>
> > > > On 31 čnc, 09:57, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > yes. Just set dbio=False in forms and do your own mymongo IO after
> > > > > accepts:
>
> > > > > On Jul 30, 11:18 am, Amit Ambardekar <amit...@gmail.com> wrote:
>
> > > > > > I want to use web2py withpymongo.
> > > > > > I don't need ORM or or anything. I just want to connect usepymongo
> > > > > > from Web2Py.
> > > > > > How can I use it inside web2py. I need it for high performance use.
>
> > > > > > AmitMy understanding is that pymongo has connection pooling 
> > > > > > builtin. -> 
> > > > > > http://api.mongodb.org/python/current/api/pymongo/connection.html

Reply via email to