[Python-modules-commits] [aiopg] 01/03: Import aiopg_0.13.1.orig.tar.gz

Piotr Ożarowski piotr at moszumanska.debian.org
Fri Sep 29 07:40:55 UTC 2017


This is an automated email from the git hooks/post-receive script.

piotr pushed a commit to branch master
in repository aiopg.

commit 2b0b14544ed0e0cf0e1dc47458c977da8e530cdc
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Fri Sep 29 09:39:12 2017 +0200

    Import aiopg_0.13.1.orig.tar.gz
---
 CHANGES.txt             |  6 ++++++
 PKG-INFO                | 23 +++++++++++++++++------
 README.rst              | 13 ++++++++-----
 aiopg.egg-info/PKG-INFO | 23 +++++++++++++++++------
 aiopg/__init__.py       |  2 +-
 aiopg/connection.py     |  7 +++++++
 aiopg/pool.py           | 20 +++++++++++++-------
 aiopg/sa/engine.py      | 11 +++++++----
 setup.cfg               |  5 ++++-
 setup.py                |  1 +
 10 files changed, 81 insertions(+), 30 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index f3a77af..002b82a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,12 @@
 CHANGES
 -------
 
+0.13.1 (2017-09-10)
+^^^^^^^^^^^^^^^^^^^
+
+* Added connection poll recycling logic #373
+
+
 0.13.0 (2016-12-02)
 ^^^^^^^^^^^^^^^^^^^
 
diff --git a/PKG-INFO b/PKG-INFO
index f4aafa9..abee651 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,18 +1,22 @@
 Metadata-Version: 1.1
 Name: aiopg
-Version: 0.13.0
+Version: 0.13.1
 Summary: Postgres integration with asyncio.
 Home-page: https://aiopg.readthedocs.io
 Author: Andrew Svetlov
 Author-email: andrew.svetlov at gmail.com
 License: BSD
 Download-URL: https://pypi.python.org/pypi/aiopg
+Description-Content-Type: UNKNOWN
 Description: aiopg
         =====
         .. image:: https://travis-ci.org/aio-libs/aiopg.svg?branch=master
-            :target: https://travis-ci.org/aio-libs/aiopg
-        .. image:: https://coveralls.io/repos/aio-libs/aiopg/badge.svg
-            :target: https://coveralls.io/r/aio-libs/aiopg
+           :target: https://travis-ci.org/aio-libs/aiopg
+        .. image:: https://codecov.io/gh/aio-libs/aiopg/branch/master/graph/badge.svg
+           :target: https://codecov.io/gh/aio-libs/aiopg
+        .. image:: https://badges.gitter.im/Join%20Chat.svg
+            :target: https://gitter.im/aio-libs/Lobby
+            :alt: Chat on Gitter
         
         **aiopg** is a library for accessing a PostgreSQL_ database
         from the asyncio_ (PEP-3156/tulip) framework. It wraps
@@ -21,7 +25,7 @@ Description: aiopg
         Example
         -------
         
-        ::
+        .. code:: python
         
             import asyncio
             import aiopg
@@ -45,7 +49,7 @@ Description: aiopg
         Example of SQLAlchemy optional integration
         ------------------------------------------
         
-        ::
+        .. code:: python
         
            import asyncio
            from aiopg.sa import create_engine
@@ -95,6 +99,12 @@ Description: aiopg
         CHANGES
         -------
         
+        0.13.1 (2017-09-10)
+        ^^^^^^^^^^^^^^^^^^^
+        
+        * Added connection poll recycling logic #373
+        
+        
         0.13.0 (2016-12-02)
         ^^^^^^^^^^^^^^^^^^^
         
@@ -294,3 +304,4 @@ Classifier: Environment :: Web Environment
 Classifier: Development Status :: 4 - Beta
 Classifier: Topic :: Database
 Classifier: Topic :: Database :: Front-Ends
+Classifier: Framework :: AsyncIO
diff --git a/README.rst b/README.rst
index 5276407..f4bd6d8 100644
--- a/README.rst
+++ b/README.rst
@@ -1,9 +1,12 @@
 aiopg
 =====
 .. image:: https://travis-ci.org/aio-libs/aiopg.svg?branch=master
-    :target: https://travis-ci.org/aio-libs/aiopg
-.. image:: https://coveralls.io/repos/aio-libs/aiopg/badge.svg
-    :target: https://coveralls.io/r/aio-libs/aiopg
+   :target: https://travis-ci.org/aio-libs/aiopg
+.. image:: https://codecov.io/gh/aio-libs/aiopg/branch/master/graph/badge.svg
+   :target: https://codecov.io/gh/aio-libs/aiopg
+.. image:: https://badges.gitter.im/Join%20Chat.svg
+    :target: https://gitter.im/aio-libs/Lobby
+    :alt: Chat on Gitter
 
 **aiopg** is a library for accessing a PostgreSQL_ database
 from the asyncio_ (PEP-3156/tulip) framework. It wraps
@@ -12,7 +15,7 @@ asynchronous features of the Psycopg database driver.
 Example
 -------
 
-::
+.. code:: python
 
     import asyncio
     import aiopg
@@ -36,7 +39,7 @@ Example
 Example of SQLAlchemy optional integration
 ------------------------------------------
 
-::
+.. code:: python
 
    import asyncio
    from aiopg.sa import create_engine
diff --git a/aiopg.egg-info/PKG-INFO b/aiopg.egg-info/PKG-INFO
index f4aafa9..abee651 100644
--- a/aiopg.egg-info/PKG-INFO
+++ b/aiopg.egg-info/PKG-INFO
@@ -1,18 +1,22 @@
 Metadata-Version: 1.1
 Name: aiopg
-Version: 0.13.0
+Version: 0.13.1
 Summary: Postgres integration with asyncio.
 Home-page: https://aiopg.readthedocs.io
 Author: Andrew Svetlov
 Author-email: andrew.svetlov at gmail.com
 License: BSD
 Download-URL: https://pypi.python.org/pypi/aiopg
+Description-Content-Type: UNKNOWN
 Description: aiopg
         =====
         .. image:: https://travis-ci.org/aio-libs/aiopg.svg?branch=master
-            :target: https://travis-ci.org/aio-libs/aiopg
-        .. image:: https://coveralls.io/repos/aio-libs/aiopg/badge.svg
-            :target: https://coveralls.io/r/aio-libs/aiopg
+           :target: https://travis-ci.org/aio-libs/aiopg
+        .. image:: https://codecov.io/gh/aio-libs/aiopg/branch/master/graph/badge.svg
+           :target: https://codecov.io/gh/aio-libs/aiopg
+        .. image:: https://badges.gitter.im/Join%20Chat.svg
+            :target: https://gitter.im/aio-libs/Lobby
+            :alt: Chat on Gitter
         
         **aiopg** is a library for accessing a PostgreSQL_ database
         from the asyncio_ (PEP-3156/tulip) framework. It wraps
@@ -21,7 +25,7 @@ Description: aiopg
         Example
         -------
         
-        ::
+        .. code:: python
         
             import asyncio
             import aiopg
@@ -45,7 +49,7 @@ Description: aiopg
         Example of SQLAlchemy optional integration
         ------------------------------------------
         
-        ::
+        .. code:: python
         
            import asyncio
            from aiopg.sa import create_engine
@@ -95,6 +99,12 @@ Description: aiopg
         CHANGES
         -------
         
+        0.13.1 (2017-09-10)
+        ^^^^^^^^^^^^^^^^^^^
+        
+        * Added connection poll recycling logic #373
+        
+        
         0.13.0 (2016-12-02)
         ^^^^^^^^^^^^^^^^^^^
         
@@ -294,3 +304,4 @@ Classifier: Environment :: Web Environment
 Classifier: Development Status :: 4 - Beta
 Classifier: Topic :: Database
 Classifier: Topic :: Database :: Front-Ends
+Classifier: Framework :: AsyncIO
diff --git a/aiopg/__init__.py b/aiopg/__init__.py
index bf467c9..b6f3462 100644
--- a/aiopg/__init__.py
+++ b/aiopg/__init__.py
@@ -10,7 +10,7 @@ from .pool import create_pool, Pool
 __all__ = ('connect', 'create_pool', 'Connection', 'Cursor', 'Pool',
            'version', 'version_info', 'DEFAULT_TIMEOUT')
 
-__version__ = '0.13.0'
+__version__ = '0.13.1'
 
 version = __version__ + ' , Python ' + sys.version
 
diff --git a/aiopg/connection.py b/aiopg/connection.py
index 8718bec..5fbbd26 100755
--- a/aiopg/connection.py
+++ b/aiopg/connection.py
@@ -111,6 +111,7 @@ class Connection:
         assert self._conn.isexecuting(), "Is conn an async at all???"
         self._fileno = self._conn.fileno()
         self._timeout = timeout
+        self._last_usage = self._loop.time()
         self._waiter = waiter
         self._writing = False
         self._cancelling = False
@@ -264,6 +265,7 @@ class Connection:
         psycopg in asynchronous mode.
 
         """
+        self._last_usage = self._loop.time()
         coro = self._cursor(name=name, cursor_factory=cursor_factory,
                             scrollable=scrollable, withhold=withhold,
                             timeout=timeout)
@@ -493,6 +495,11 @@ class Connection:
         return self._timeout
 
     @property
+    def last_usage(self):
+        """Return time() when connection was used."""
+        return self._last_usage
+
+    @property
     def echo(self):
         """Return echo mode status."""
         return self._echo
diff --git a/aiopg/pool.py b/aiopg/pool.py
index e391283..f5df9d2 100644
--- a/aiopg/pool.py
+++ b/aiopg/pool.py
@@ -17,20 +17,21 @@ PY_341 = sys.version_info >= (3, 4, 1)
 
 
 def create_pool(dsn=None, *, minsize=1, maxsize=10,
-                loop=None, timeout=TIMEOUT,
+                loop=None, timeout=TIMEOUT, pool_recycle=-1,
                 enable_json=True, enable_hstore=True, enable_uuid=True,
                 echo=False, on_connect=None,
                 **kwargs):
     coro = _create_pool(dsn=dsn, minsize=minsize, maxsize=maxsize, loop=loop,
-                        timeout=timeout, enable_json=enable_json,
-                        enable_hstore=enable_hstore, enable_uuid=enable_uuid,
-                        echo=echo, on_connect=on_connect, **kwargs)
+                        timeout=timeout, pool_recycle=pool_recycle,
+                        enable_json=enable_json, enable_hstore=enable_hstore,
+                        enable_uuid=enable_uuid, echo=echo,
+                        on_connect=on_connect, **kwargs)
     return _PoolContextManager(coro)
 
 
 @asyncio.coroutine
 def _create_pool(dsn=None, *, minsize=1, maxsize=10,
-                 loop=None, timeout=TIMEOUT,
+                 loop=None, timeout=TIMEOUT, pool_recycle=-1,
                  enable_json=True, enable_hstore=True, enable_uuid=True,
                  echo=False, on_connect=None,
                  **kwargs):
@@ -40,7 +41,7 @@ def _create_pool(dsn=None, *, minsize=1, maxsize=10,
     pool = Pool(dsn, minsize, maxsize, loop, timeout,
                 enable_json=enable_json, enable_hstore=enable_hstore,
                 enable_uuid=enable_uuid, echo=echo, on_connect=on_connect,
-                **kwargs)
+                pool_recycle=pool_recycle, **kwargs)
     if minsize > 0:
         with (yield from pool._cond):
             yield from pool._fill_free_pool(False)
@@ -52,7 +53,7 @@ class Pool(asyncio.AbstractServer):
 
     def __init__(self, dsn, minsize, maxsize, loop, timeout, *,
                  enable_json, enable_hstore, enable_uuid, echo,
-                 on_connect, **kwargs):
+                 on_connect, pool_recycle, **kwargs):
         if minsize < 0:
             raise ValueError("minsize should be zero or greater")
         if maxsize < minsize and maxsize != 0:
@@ -61,6 +62,7 @@ class Pool(asyncio.AbstractServer):
         self._minsize = minsize
         self._loop = loop
         self._timeout = timeout
+        self._recycle = pool_recycle
         self._enable_json = enable_json
         self._enable_hstore = enable_hstore
         self._enable_uuid = enable_uuid
@@ -187,6 +189,10 @@ class Pool(asyncio.AbstractServer):
             conn = self._free[-1]
             if conn.closed:
                 self._free.pop()
+            elif self._recycle > -1 \
+                    and self._loop.time() - conn.last_usage > self._recycle:
+                conn.close()
+                self._free.pop()
             else:
                 self._free.rotate()
             n += 1
diff --git a/aiopg/sa/engine.py b/aiopg/sa/engine.py
index 6b1cbd4..94620fd 100644
--- a/aiopg/sa/engine.py
+++ b/aiopg/sa/engine.py
@@ -44,7 +44,8 @@ _dialect._has_native_hstore = True
 
 
 def create_engine(dsn=None, *, minsize=1, maxsize=10, loop=None,
-                  dialect=_dialect, timeout=TIMEOUT, **kwargs):
+                  dialect=_dialect, timeout=TIMEOUT, pool_recycle=-1,
+                  **kwargs):
     """A coroutine for Engine creation.
 
     Returns Engine instance with embedded connection pool.
@@ -54,17 +55,19 @@ def create_engine(dsn=None, *, minsize=1, maxsize=10, loop=None,
 
     coro = _create_engine(dsn=dsn, minsize=minsize, maxsize=maxsize,
                           loop=loop, dialect=dialect, timeout=timeout,
-                          **kwargs)
+                          pool_recycle=pool_recycle, **kwargs)
     return _EngineContextManager(coro)
 
 
 @asyncio.coroutine
 def _create_engine(dsn=None, *, minsize=1, maxsize=10, loop=None,
-                   dialect=_dialect, timeout=TIMEOUT, **kwargs):
+                   dialect=_dialect, timeout=TIMEOUT, pool_recycle=-1,
+                   **kwargs):
     if loop is None:
         loop = asyncio.get_event_loop()
     pool = yield from aiopg.create_pool(dsn, minsize=minsize, maxsize=maxsize,
-                                        loop=loop, timeout=timeout, **kwargs)
+                                        loop=loop, timeout=timeout,
+                                        pool_recycle=pool_recycle, **kwargs)
     conn = yield from pool.acquire()
     try:
         real_dsn = conn.dsn
diff --git a/setup.cfg b/setup.cfg
index a576fa4..1fe39b6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,11 @@
 [tool:pytest]
 timeout = 300
 
+[coverage:run]
+branch = true
+source = aiopg,tests
+
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index 94ae7e0..599d9c0 100644
--- a/setup.py
+++ b/setup.py
@@ -42,6 +42,7 @@ classifiers = [
     'Development Status :: 4 - Beta',
     'Topic :: Database',
     'Topic :: Database :: Front-Ends',
+    'Framework :: AsyncIO',
 ]
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/aiopg.git



More information about the Python-modules-commits mailing list