diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 3bcb84c..3efc189 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -11,9 +11,10 @@ wraps Psycopg2, the `Psycopg2 documentation`_ must be used alongside Momoko's. The principle ------------- -All of the :py:meth:`~momoko.Pool` and :py:meth:`~momoko.Connection` methods return -_futures. There are some notable exceptions like :py:meth:`~momoko.Pool.close` - make sure -to consule API documentation for the details. +Almost every method of :py:meth:`~momoko.Pool` and :py:meth:`~momoko.Connection` +returns a `future`_. There are some notable exceptions, like +:py:meth:`~momoko.Pool.close`; be sure to consult API documentation for the +details. These future objects can be simply ``yield``-ed in Tornado methods decorated with ``gen.coroutine``. For SQL execution related methods these futures resolve to corresponding cursor objects. @@ -226,4 +227,4 @@ Here is the server-side cursor example (based on the code in momoko unittests):: .. _Wait: http://tornado.readthedocs.org/en/stable/gen.html#tornado.gen.Wait .. _WaitAll: http://tornado.readthedocs.org/en/stable/gen.html#tornado.gen.WaitAll .. _exceptions: http://initd.org/psycopg/docs/module.html#exceptions -.. _futures: http://tornado.readthedocs.org/en/latest/concurrent.html +.. _future: http://tornado.readthedocs.org/en/latest/concurrent.html diff --git a/momoko/connection.py b/momoko/connection.py index 79d9ab1..dff4d17 100644 --- a/momoko/connection.py +++ b/momoko/connection.py @@ -175,7 +175,7 @@ class Pool(object): connect to database during :py:meth:`momoko.Pool.connect`. :param int reconnect_interval: - If database server becomes unavailble, the pool will try to reestablish + If database server becomes unavailable, the pool will try to reestablish the connection. The attempt frequency is ``reconnect_interval`` milliseconds. @@ -244,7 +244,7 @@ def __init__(self, self.conns = ConnectionContainer() self._last_connect_time = 0 - self._no_conn_availble_error = self.DatabaseNotAvailable("No database connection available") + self._no_conn_available_error = self.DatabaseNotAvailable("No database connection available") self.shrink_period = shrink_period self.shrink_delay = shrink_delay self.auto_shrink = auto_shrink @@ -286,13 +286,13 @@ def getconn(self, ping=True): """ Acquire connection from the pool. - You can then use this connection for subsequest queries. + You can then use this connection for subsequent queries. Just use ``connection.execute`` instead of ``Pool.execute``. Make sure to return connection to the pool by calling :py:meth:`momoko.Pool.putconn`, - otherwise the connection will remain forever-busy and you'll starvate your pool quickly. + otherwise the connection will remain forever busy and you'll starve your pool. - Returns future that resolves to the acquired connection object. + Returns a future that resolves to the acquired connection object. :param boolean ping: Whether to ping the connection before returning it by executing :py:meth:`momoko.Connection.ping`. @@ -307,7 +307,7 @@ def getconn(self, ping=True): def on_reanimate_done(fut): if self.conns.all_dead: - future.set_exception(self._no_conn_availble_error) + future.set_exception(self._no_conn_available_error) return f = self.conns.acquire() assert isinstance(f, Future) @@ -333,7 +333,7 @@ def putconn(self, connection): self.conns.release(connection) if self.conns.all_dead: - self.conns.abort_waiting_queue(self._no_conn_availble_error) + self.conns.abort_waiting_queue(self._no_conn_available_error) @contextmanager def manage(self, connection): @@ -495,7 +495,7 @@ def _retry(self, retry, what, conn, keep, future): self.ioloop.add_future(conn.connect(), what) return else: - future.set_exception(self._no_conn_availble_error) + future.set_exception(self._no_conn_available_error) else: future.set_exc_info(sys.exc_info()) if not keep: @@ -580,7 +580,7 @@ def on_ping_done(ping_fut): ping_fut.result() except psycopg2.Error as error: if conn.closed: - ping_future.set_exception(self._no_conn_availble_error) + ping_future.set_exception(self._no_conn_available_error) else: ping_future.set_exc_info(sys.exc_info()) self.putconn(conn) diff --git a/tests.py b/tests.py index 26e2e3b..4ccae9d 100644 --- a/tests.py +++ b/tests.py @@ -667,7 +667,7 @@ def test_request_queueing(self): self.run_parallel_queries(self.pool_size*2) def test_parallel_queries_after_reconnect_all(self): - """Testing that pool still queries database in parallel after ALL connections were closeded""" + """Testing that pool still queries database in parallel after ALL connections were closed""" self.shutter(self.db) self.run_parallel_queries()