FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
362 stars 73 forks source link

Pool and connect() with Momoko 2.0.0 #107

Closed vejnar closed 9 years ago

vejnar commented 9 years ago

I am trying to switch to Momoko 2.0.0 but I have a two problems.

future = application.db.connect()
ioloop.add_future(future, lambda f: ioloop.stop())
ioloop.start()

I am using a Pool. When I init one and directly call execute() on it, I get:

assert self.conns.dead, "BUG: dont' call reanimate when there is no one to reanimate"

Which is fixable by adding the 3 lines above. It wasn't like that with the previous version. Is connecting first necessary now? Could you please clarify? BTW not requiring a first connect would be nice.

Thanks a lot for your help and for developing and maintaining Momoko. It's great!

haizaar commented 9 years ago

Yes, you need to connect. Previously Pool was connecting implicitly in the constructor. I have changed it for several reasons:

Regarding your second question: Pool constructor will do self.ioloop = ioloop or IOLoop.instance() if you don't pass your own ioloop instance. The tutorial does this explicitly to demonstrate the ability.

vejnar commented 9 years ago

OK. Thanks. Would be nice to clarify that in the tutorial.

haizaar commented 9 years ago

You are welcome to submit a pull request :)