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

Piotr Ożarowski piotr at moszumanska.debian.org
Sat Nov 5 18:31:15 UTC 2016


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

piotr pushed a commit to branch master
in repository aiopg.

commit 01d91607b9a92502425957b86dde6f6a4fc06d6b
Author: Piotr Ożarowski <piotr at debian.org>
Date:   Sat Nov 5 19:28:33 2016 +0100

    Import aiopg_0.12.0.orig.tar.gz
---
 CHANGES.txt             |  7 +++++++
 PKG-INFO                | 10 +++++++++-
 aiopg.egg-info/PKG-INFO | 10 +++++++++-
 aiopg/__init__.py       |  2 +-
 aiopg/connection.py     | 41 +++++++++++++++++++++++++++--------------
 aiopg/pool.py           | 14 +++++++++-----
 setup.cfg               |  1 +
 setup.py                |  1 +
 8 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index b0e0b99..9b6dcd8 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,13 @@
 CHANGES
 -------
 
+0.12.0 (2016-10-09)
+^^^^^^^^^^^^^^^^^^^
+
+* Add an on_connect callback parameter to pool #141
+
+* Fixed connection to work under both windows and posix based systems #142
+
 0.11.0 (2016-09-12)
 ^^^^^^^^^^^^^^^^^^^
 
diff --git a/PKG-INFO b/PKG-INFO
index a3ed5fb..21d4917 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aiopg
-Version: 0.11.0
+Version: 0.12.0
 Summary: Postgres integration with asyncio.
 Home-page: https://aiopg.readthedocs.io
 Author: Andrew Svetlov
@@ -95,6 +95,13 @@ Description: aiopg
         CHANGES
         -------
         
+        0.12.0 (2016-10-09)
+        ^^^^^^^^^^^^^^^^^^^
+        
+        * Add an on_connect callback parameter to pool #141
+        
+        * Fixed connection to work under both windows and posix based systems #142
+        
         0.11.0 (2016-09-12)
         ^^^^^^^^^^^^^^^^^^^
         
@@ -268,6 +275,7 @@ Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Operating System :: POSIX
 Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
 Classifier: Environment :: Web Environment
 Classifier: Development Status :: 4 - Beta
 Classifier: Topic :: Database
diff --git a/aiopg.egg-info/PKG-INFO b/aiopg.egg-info/PKG-INFO
index a3ed5fb..21d4917 100644
--- a/aiopg.egg-info/PKG-INFO
+++ b/aiopg.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: aiopg
-Version: 0.11.0
+Version: 0.12.0
 Summary: Postgres integration with asyncio.
 Home-page: https://aiopg.readthedocs.io
 Author: Andrew Svetlov
@@ -95,6 +95,13 @@ Description: aiopg
         CHANGES
         -------
         
+        0.12.0 (2016-10-09)
+        ^^^^^^^^^^^^^^^^^^^
+        
+        * Add an on_connect callback parameter to pool #141
+        
+        * Fixed connection to work under both windows and posix based systems #142
+        
         0.11.0 (2016-09-12)
         ^^^^^^^^^^^^^^^^^^^
         
@@ -268,6 +275,7 @@ Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
 Classifier: Operating System :: POSIX
 Classifier: Operating System :: MacOS :: MacOS X
+Classifier: Operating System :: Microsoft :: Windows
 Classifier: Environment :: Web Environment
 Classifier: Development Status :: 4 - Beta
 Classifier: Topic :: Database
diff --git a/aiopg/__init__.py b/aiopg/__init__.py
index 8281199..76d9924 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.11.0'
+__version__ = '0.12.0'
 
 version = __version__ + ' , Python ' + sys.version
 
diff --git a/aiopg/connection.py b/aiopg/connection.py
old mode 100644
new mode 100755
index 26531f5..98af36b
--- a/aiopg/connection.py
+++ b/aiopg/connection.py
@@ -1,11 +1,12 @@
 import asyncio
 import contextlib
 import errno
-import fcntl
+import select
 import sys
 import traceback
 import warnings
 import weakref
+import platform
 
 import psycopg2
 from psycopg2.extensions import (
@@ -22,6 +23,10 @@ __all__ = ('connect',)
 TIMEOUT = 60.0
 PY_341 = sys.version_info >= (3, 4, 1)
 
+# Windows specific error code, not in errno for some reason, and doesnt map
+# to OSError.errno EBADF
+WSAENOTSOCK = 10038
+
 
 @asyncio.coroutine
 def _enable_hstore(conn):
@@ -82,6 +87,13 @@ def _connect(dsn=None, *, timeout=TIMEOUT, loop=None, enable_json=True,
     return conn
 
 
+def _is_bad_descriptor_error(os_error):
+    if platform.system() == 'Windows':  # pragma: no cover
+        return os_error.winerror == WSAENOTSOCK
+    else:
+        return os_error.errno == errno.EBADF
+
+
 class Connection:
     """Low-level asynchronous interface for wrapped psycopg2 connection.
 
@@ -124,14 +136,14 @@ class Connection:
         except (psycopg2.Warning, psycopg2.Error) as exc:
             if self._fileno is not None:
                 try:
-                    fcntl.fcntl(self._fileno, fcntl.F_GETFD)
+                    select.select([self._fileno], [], [], 0)
                 except OSError as os_exc:
-                    if os_exc.errno == errno.EBADF:
+                    if _is_bad_descriptor_error(os_exc):
                         with contextlib.suppress(OSError):
                             self._loop.remove_reader(self._fileno)
-                finally:
-                    # forget a bad file descriptor, don't try to touch it
-                    self._fileno = None
+                            # forget a bad file descriptor, don't try to
+                            # touch it
+                            self._fileno = None
 
             try:
                 if self._writing:
@@ -194,14 +206,15 @@ class Connection:
 
         @asyncio.coroutine
         def cancel():
-            if not self._isexecuting():
-                return
             self._waiter = create_future(self._loop)
             self._conn.cancel()
             try:
-                yield from self._waiter
+                yield from asyncio.wait_for(self._waiter, timeout,
+                                            loop=self._loop)
             except psycopg2.extensions.QueryCanceledError:
                 pass
+            except asyncio.TimeoutError:
+                self._close()
 
         try:
             yield from asyncio.wait_for(self._waiter, timeout, loop=self._loop)
@@ -254,7 +267,7 @@ class Connection:
                                      scrollable=scrollable, withhold=withhold)
         return impl
 
-    def close(self):
+    def _close(self):
         """Remove the connection from the event_loop and close it."""
         # N.B. If connection contains uncommitted transaction the
         # transaction will be discarded
@@ -267,6 +280,9 @@ class Connection:
         if self._waiter is not None and not self._waiter.done():
             self._waiter.set_exception(
                 psycopg2.OperationalError("Connection closed"))
+
+    def close(self):
+        self._close()
         ret = create_future(self._loop)
         ret.set_result(None)
         return ret
@@ -328,11 +344,8 @@ class Connection:
             "tpc_recover cannot be used in asynchronous mode")
 
     @asyncio.coroutine
-    def cancel(self, timeout=None):
+    def cancel(self):
         """Cancel the current database operation."""
-        if timeout is not None:
-            warnings.warn('timeout parameter is deprecated and never used',
-                          DeprecationWarning)
         if self._waiter is not None:
             self._waiter.cancel()
         if not self._isexecuting():
diff --git a/aiopg/pool.py b/aiopg/pool.py
index 64b7591..e391283 100644
--- a/aiopg/pool.py
+++ b/aiopg/pool.py
@@ -19,12 +19,12 @@ PY_341 = sys.version_info >= (3, 4, 1)
 def create_pool(dsn=None, *, minsize=1, maxsize=10,
                 loop=None, timeout=TIMEOUT,
                 enable_json=True, enable_hstore=True, enable_uuid=True,
-                echo=False,
+                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, **kwargs)
+                        echo=echo, on_connect=on_connect, **kwargs)
     return _PoolContextManager(coro)
 
 
@@ -32,14 +32,14 @@ def create_pool(dsn=None, *, minsize=1, maxsize=10,
 def _create_pool(dsn=None, *, minsize=1, maxsize=10,
                  loop=None, timeout=TIMEOUT,
                  enable_json=True, enable_hstore=True, enable_uuid=True,
-                 echo=False,
+                 echo=False, on_connect=None,
                  **kwargs):
     if loop is None:
         loop = asyncio.get_event_loop()
 
     pool = Pool(dsn, minsize, maxsize, loop, timeout,
                 enable_json=enable_json, enable_hstore=enable_hstore,
-                enable_uuid=enable_uuid, echo=echo,
+                enable_uuid=enable_uuid, echo=echo, on_connect=on_connect,
                 **kwargs)
     if minsize > 0:
         with (yield from pool._cond):
@@ -51,7 +51,8 @@ class Pool(asyncio.AbstractServer):
     """Connection pool"""
 
     def __init__(self, dsn, minsize, maxsize, loop, timeout, *,
-                 enable_json, enable_hstore, enable_uuid, echo, **kwargs):
+                 enable_json, enable_hstore, enable_uuid, echo,
+                 on_connect, **kwargs):
         if minsize < 0:
             raise ValueError("minsize should be zero or greater")
         if maxsize < minsize and maxsize != 0:
@@ -64,6 +65,7 @@ class Pool(asyncio.AbstractServer):
         self._enable_hstore = enable_hstore
         self._enable_uuid = enable_uuid
         self._echo = echo
+        self._on_connect = on_connect
         self._conn_kwargs = kwargs
         self._acquiring = 0
         self._free = collections.deque(maxlen=maxsize or None)
@@ -171,6 +173,8 @@ class Pool(asyncio.AbstractServer):
                     assert not conn.closed, conn
                     assert conn not in self._used, (conn, self._used)
                     self._used.add(conn)
+                    if self._on_connect is not None:
+                        yield from self._on_connect(conn)
                     return conn
                 else:
                     yield from self._cond.wait()
diff --git a/setup.cfg b/setup.cfg
index 21307fd..a576fa4 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,4 +1,5 @@
 [tool:pytest]
+timeout = 300
 
 [egg_info]
 tag_build = 
diff --git a/setup.py b/setup.py
index 9b937b3..726fcb5 100644
--- a/setup.py
+++ b/setup.py
@@ -37,6 +37,7 @@ classifiers = [
     'Programming Language :: Python :: 3.5',
     'Operating System :: POSIX',
     'Operating System :: MacOS :: MacOS X',
+    'Operating System :: Microsoft :: Windows',
     'Environment :: Web Environment',
     'Development Status :: 4 - Beta',
     'Topic :: Database',

-- 
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