From 86b6c022f0284e33be795e525bf25c86e8d6b3eb Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Mon, 13 Apr 2020 14:20:09 -0400 Subject: [PATCH] Update DEFAULT_POSTGRES_MAX_POOL_SIZE Even though ``0`` is documented as the max pool size in the aiopg docs, setting it to 0 causes an exception in `aiopg.pool.Pool._fill_free_pool`: ``` File "/Users/gavinr/Source/PSE/anabroker/env/lib/python3.7/site-packages/aiopg/pool.py", line 208, in _fill_free_pool if override_min and self.size < self.maxsize: TypeError: '<' not supported between instances of 'int' and 'NoneType' ``` Set to the same default as aiopg, @ 10. --- README.rst | 44 +++++++++++++++++++++--------------------- VERSION | 2 +- docs/configuration.rst | 44 +++++++++++++++++++++--------------------- sprockets_postgres.py | 12 ++++++------ 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/README.rst b/README.rst index bedaf84..f031691 100644 --- a/README.rst +++ b/README.rst @@ -21,28 +21,28 @@ Configuration ------------- The following table details the environment variable configuration options: -+---------------------------------+--------------------------------------------------+-------------------+ -| Variable | Definition | Default | -+=================================+==================================================+===================+ -| ``POSTGRES_URL`` | The PostgreSQL URL to connect to | | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_MAX_POOL_SIZE`` | Maximum connection count to Postgres per backend | ``0`` (Unlimited) | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_MIN_POOL_SIZE`` | Minimum or starting pool size. | ``1`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_CONNECTION_TIMEOUT`` | The maximum time in seconds to spend attempting | ``10`` | -| | to create a new connection. | | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_CONNECTION_TTL`` | Time-to-life in seconds for a pooled connection. | ``300`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_QUERY_TIMEOUT`` | Maximum execution time for a query in seconds. | ``60`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_HSTORE`` | Enable HSTORE support in the client. | ``FALSE`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_JSON`` | Enable JSON support in the client. | ``FALSE`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_UUID`` | Enable UUID support in the client. | ``TRUE`` | -+---------------------------------+--------------------------------------------------+-------------------+ ++---------------------------------+--------------------------------------------------+-----------+ +| Variable | Definition | Default | ++=================================+==================================================+===========+ +| ``POSTGRES_URL`` | The PostgreSQL URL to connect to | | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_MAX_POOL_SIZE`` | Maximum connection count to Postgres per backend | ``10`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_MIN_POOL_SIZE`` | Minimum or starting pool size. | ``1`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_CONNECTION_TIMEOUT`` | The maximum time in seconds to spend attempting | ``10`` | +| | to create a new connection. | | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_CONNECTION_TTL`` | Time-to-life in seconds for a pooled connection. | ``300`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_QUERY_TIMEOUT`` | Maximum execution time for a query in seconds. | ``60`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_HSTORE`` | Enable HSTORE support in the client. | ``FALSE`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_JSON`` | Enable JSON support in the client. | ``FALSE`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_UUID`` | Enable UUID support in the client. | ``TRUE`` | ++---------------------------------+--------------------------------------------------+-----------+ Requirements ------------ diff --git a/VERSION b/VERSION index 7dea76e..6d7de6e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 +1.0.2 diff --git a/docs/configuration.rst b/docs/configuration.rst index 15a47ac..53a0329 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -3,25 +3,25 @@ Configuration :py:mod:`sprockets-postgres ` is configured via environment variables. The following table details the configuration options and their defaults. -+---------------------------------+--------------------------------------------------+-------------------+ -| Variable | Definition | Default | -+=================================+==================================================+===================+ -| ``POSTGRES_URL`` | The PostgreSQL URL to connect to | | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_MAX_POOL_SIZE`` | Maximum connection count to Postgres per backend | ``0`` (Unlimited) | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_MIN_POOL_SIZE`` | Minimum or starting pool size. | ``1`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_CONNECTION_TIMEOUT`` | The maximum time in seconds to spend attempting | ``10`` | -| | to create a new connection. | | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_CONNECTION_TTL`` | Time-to-life in seconds for a pooled connection. | ``300`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_QUERY_TIMEOUT`` | Maximum execution time for a query in seconds. | ``60`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_HSTORE`` | Enable HSTORE support in the client. | ``FALSE`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_JSON`` | Enable JSON support in the client. | ``FALSE`` | -+---------------------------------+--------------------------------------------------+-------------------+ -| ``POSTGRES_UUID`` | Enable UUID support in the client. | ``TRUE`` | -+---------------------------------+--------------------------------------------------+-------------------+ ++---------------------------------+--------------------------------------------------+-----------+ +| Variable | Definition | Default | ++=================================+==================================================+===========+ +| ``POSTGRES_URL`` | The PostgreSQL URL to connect to | | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_MAX_POOL_SIZE`` | Maximum connection count to Postgres per backend | ``10`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_MIN_POOL_SIZE`` | Minimum or starting pool size. | ``1`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_CONNECTION_TIMEOUT`` | The maximum time in seconds to spend attempting | ``10`` | +| | to create a new connection. | | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_CONNECTION_TTL`` | Time-to-life in seconds for a pooled connection. | ``300`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_QUERY_TIMEOUT`` | Maximum execution time for a query in seconds. | ``60`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_HSTORE`` | Enable HSTORE support in the client. | ``FALSE`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_JSON`` | Enable JSON support in the client. | ``FALSE`` | ++---------------------------------+--------------------------------------------------+-----------+ +| ``POSTGRES_UUID`` | Enable UUID support in the client. | ``TRUE`` | ++---------------------------------+--------------------------------------------------+-----------+ diff --git a/sprockets_postgres.py b/sprockets_postgres.py index a2d2942..5b23848 100644 --- a/sprockets_postgres.py +++ b/sprockets_postgres.py @@ -19,8 +19,8 @@ DEFAULT_POSTGRES_CONNECTION_TIMEOUT = 10 DEFAULT_POSTGRES_CONNECTION_TTL = 300 DEFAULT_POSTGRES_HSTORE = 'FALSE' DEFAULT_POSTGRES_JSON = 'FALSE' -DEFAULT_POSTGRES_MAX_POOL_SIZE = 0 -DEFAULT_POSTGRES_MIN_POOL_SIZE = 1 +DEFAULT_POSTGRES_MAX_POOL_SIZE = '10' +DEFAULT_POSTGRES_MIN_POOL_SIZE = '1' DEFAULT_POSTGRES_QUERY_TIMEOUT = 120 DEFAULT_POSTGRES_UUID = 'TRUE' @@ -368,14 +368,14 @@ class ApplicationMixin: return self.stop(loop) self._postgres_pool = pool.Pool( os.environ['POSTGRES_URL'], - minsize=int( - os.environ.get( - 'POSTGRES_MIN_POOL_SIZE', - DEFAULT_POSTGRES_MIN_POOL_SIZE)), maxsize=int( os.environ.get( 'POSTGRES_MAX_POOL_SIZE', DEFAULT_POSTGRES_MAX_POOL_SIZE)), + minsize=int( + os.environ.get( + 'POSTGRES_MIN_POOL_SIZE', + DEFAULT_POSTGRES_MIN_POOL_SIZE)), timeout=int( os.environ.get( 'POSTGRES_CONNECT_TIMEOUT',