Closed vejnar closed 9 years ago
Yes, you need to connect
. Previously Pool
was connecting implicitly in the constructor. I have changed it for several reasons:
Pool
and wait it to connect to db before you start listening. Previously Pool
used a on_connect_callback
that you can use to get notified that all connection attempts are finished. Now we use futures, but you can not return a future from a constructor, so a separate method is required. This approach also hints a user that he'll better wait this future to resolve to make sure that database is ready. I guess previously some people were just initializing Pool "blindly" and since connections were created quite fast, never noticed that they have a race condition - which may work, but it's not how we want to build software, right?Pool
object initialization. And there is no real need to bind them together. So I did the separation.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.
OK. Thanks. Would be nice to clarify that in the tutorial.
You are welcome to submit a pull request :)
I am trying to switch to Momoko 2.0.0 but I have a two problems.
connect()
method:I am using a
Pool
. When I init one and directly callexecute()
on it, I get: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.
ioloop = IOLoop.instance()
is passed to init aPool
. Is that necessary?Thanks a lot for your help and for developing and maintaining Momoko. It's great!