]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
3 years agofix: install typing_extensions on Python < 3.10
Daniele Varrazzo [Sat, 19 Mar 2022 22:11:07 +0000 (23:11 +0100)] 
fix: install typing_extensions on Python < 3.10

For some reasons tests pass, but it's necessary.

Close #252.

3 years agoMerge branch 'pgconn-in-exception'
Daniele Varrazzo [Sat, 19 Mar 2022 15:06:55 +0000 (16:06 +0100)] 
Merge branch 'pgconn-in-exception'

3 years agodocs: document PGconn needs_password and used_password attributes
Denis Laxalde [Sat, 19 Mar 2022 08:46:58 +0000 (09:46 +0100)] 
docs: document PGconn needs_password and used_password attributes

This improves the documentation of Error class, which refers to those
in the new pgconn attribute documentation.

3 years agodocs: specify that ANY() is available in psycopg2 too
Daniele Varrazzo [Fri, 18 Mar 2022 16:00:51 +0000 (17:00 +0100)] 
docs: specify that ANY() is available in psycopg2 too

3 years agodoc: give more context to disconnection detection recipe
poulpe [Thu, 17 Mar 2022 13:18:46 +0000 (14:18 +0100)] 
doc: give more context to disconnection detection recipe

3 years agodocs: add docs for `Error.pgconn` and `Error.pgresult`
Daniele Varrazzo [Sun, 13 Mar 2022 00:10:46 +0000 (00:10 +0000)] 
docs: add docs for `Error.pgconn` and `Error.pgresult`

3 years agofeat: add `Error.pgresult` property
Daniele Varrazzo [Sat, 12 Mar 2022 22:57:55 +0000 (22:57 +0000)] 
feat: add `Error.pgresult` property

It might be useful for the same reason `pgconn` is.

For symmetry convert `pgconn` to a read-only attribute too.

3 years agofeat: add `Error.pgconn` attribute
Daniele Varrazzo [Fri, 11 Mar 2022 19:48:08 +0000 (19:48 +0000)] 
feat: add `Error.pgconn` attribute

Might be useful to investigate errors such as bad/missing password. See #242
for details.

3 years agodoc: fix duplications in class exceptions table titles
Daniele Varrazzo [Sun, 13 Mar 2022 00:29:09 +0000 (00:29 +0000)] 
doc: fix duplications in class exceptions table titles

3 years agofix(c): fix portable endian aliases on different BSD flavours
Daniele Varrazzo [Fri, 11 Mar 2022 20:07:03 +0000 (20:07 +0000)] 
fix(c): fix portable endian aliases on different BSD flavours

See the commit at:
https://github.com/linux-sunxi/sunxi-tools/commit/384ff6473455da1a24b5037b358591f44f3bbf57

Close #241

3 years agochore: bump version number to 3.0.10
Daniele Varrazzo [Thu, 3 Mar 2022 01:53:41 +0000 (01:53 +0000)] 
chore: bump version number to 3.0.10

3 years agodoc: fix typo in comment
Daniele Varrazzo [Wed, 2 Mar 2022 23:48:15 +0000 (23:48 +0000)] 
doc: fix typo in comment

3 years agofix: don't raise error accessing Cursor.description after COPY_OUT
Daniele Varrazzo [Wed, 2 Mar 2022 00:48:30 +0000 (00:48 +0000)] 
fix: don't raise error accessing Cursor.description after COPY_OUT

COPY_OUT result advertises the number of columns but not their names (or
types). Use a surrogate name for description (which is more useful than
returning `None`, because at lest it tells how many columns were
emitted).

Close #235.

3 years agoMerge branch 'fix-231'
Daniele Varrazzo [Wed, 2 Mar 2022 02:53:06 +0000 (02:53 +0000)] 
Merge branch 'fix-231'

3 years agotest(win32): skip Ctrl-C test on Windows
Daniele Varrazzo [Wed, 2 Mar 2022 00:57:51 +0000 (00:57 +0000)] 
test(win32): skip Ctrl-C test on Windows

As much as I've tried, haven't been able to send a Ctrl-C. Tests fail on
"ctrl-c not received".

3 years agofix: Cancel query on Ctrl-C
Daniele Varrazzo [Tue, 22 Feb 2022 03:02:13 +0000 (04:02 +0100)] 
fix: Cancel query on Ctrl-C

On KeyboardInterrupt, send a cancel to the server and keep waiting for
the result of the cancel, which is expected to raise a QueryCanceled,
then re-raise KeyboardInterrupt.

Before this, the connection was left in ACTIVE state, so it couldn't be rolled
back.

Only fixed on sync connections. Left a failing test for async
connections; the test fails with an output from the script such as:

    error ignored in rollback on <psycopg.AsyncConnection [ACTIVE] ...>:
    sending query failed: another command is already in progress
    Traceback (most recent call last):
      File "<string>", line 27, in <module>
      File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.8/asyncio/base_events.py", line 603, in run_until_complete
        self.run_forever()
      File "/usr/lib/python3.8/asyncio/base_events.py", line 570, in run_forever
        self._run_once()
      File "/usr/lib/python3.8/asyncio/base_events.py", line 1823, in _run_once
        event_list = self._selector.select(timeout)
      File "/usr/lib/python3.8/selectors.py", line 468, in select
        fd_event_list = self._selector.poll(timeout, max_ev)
    KeyboardInterrupt

And the except branch in `AsyncConnection.wait()` is not reached.

See #231

3 years agochore(pool): bump to next rev release
Daniele Varrazzo [Sat, 19 Feb 2022 18:04:28 +0000 (19:04 +0100)] 
chore(pool): bump to next rev release

3 years agodocs: declare psycopg 3.0.9 released
Daniele Varrazzo [Sat, 19 Feb 2022 17:52:18 +0000 (18:52 +0100)] 
docs: declare psycopg 3.0.9 released

3 years agochore(pool): Bump pool version to 3.1.1 pool-3.1.1
Daniele Varrazzo [Sat, 19 Feb 2022 17:23:48 +0000 (18:23 +0100)] 
chore(pool):  Bump pool version to 3.1.1

3 years agorefactor(pool): update some debug logging
Daniele Varrazzo [Sat, 19 Feb 2022 17:19:31 +0000 (18:19 +0100)] 
refactor(pool): update some debug logging

Drop debug logging on `MaintenanceTask.init()`, which is not
particularly useful. Add debug entries on tasks `run()` early bailout,
which is a more interesting condition to follow (and would have allowed
to spot #230 more easily).

3 years agoMerge branch 'fix-230'
Daniele Varrazzo [Sat, 19 Feb 2022 17:03:55 +0000 (18:03 +0100)] 
Merge branch 'fix-230'

Close #230.

3 years agofix(pool): set the open flag before starting the maintenance tasks
Daniele Varrazzo [Sat, 19 Feb 2022 16:34:37 +0000 (17:34 +0100)] 
fix(pool): set the open flag before starting the maintenance tasks

Failing to do so we might trigger the test in `MaintenanceTask.run()`
and find the pool closed, so discard the operation. It usually doesn't
happen, but with a few combination of IO operation it does happen: see
https://github.com/psycopg/psycopg/issues/230 for details.

3 years agotest(pool): add test to show deadlock on logging
Daniele Varrazzo [Sat, 19 Feb 2022 14:39:37 +0000 (15:39 +0100)] 
test(pool): add test to show deadlock on logging

This deadlock seems reproducible at least on Python 3.8 and 3.10 on
Linux. It is caused by the logging statement in
``MaintenanceTask.__init__``: even just a ``print()`` there causes the lock.

See https://github.com/psycopg/psycopg/issues/230 for more details.

3 years agochore(pool): bump to next pool version
Daniele Varrazzo [Sat, 19 Feb 2022 14:38:48 +0000 (15:38 +0100)] 
chore(pool): bump to next pool version

3 years agoMore regular and compact auto-generated exceptions
Daniele Varrazzo [Sat, 12 Feb 2022 17:55:09 +0000 (18:55 +0100)] 
More regular and compact auto-generated exceptions

Also drop unneeded flake8 config file.

3 years agoSet up the sqlstate-exception mapping using init_subclass
Daniele Varrazzo [Fri, 11 Feb 2022 22:16:51 +0000 (23:16 +0100)] 
Set up the sqlstate-exception mapping using init_subclass

3 years agoMerge branch 'fix-225'
Daniele Varrazzo [Fri, 11 Feb 2022 20:33:14 +0000 (21:33 +0100)] 
Merge branch 'fix-225'

3 years agoAdd doc section to refer to the exceptions list
Daniele Varrazzo [Fri, 11 Feb 2022 19:32:55 +0000 (20:32 +0100)] 
Add doc section to refer to the exceptions list

Also clarify Error.sqlstate and further errors doc cleanup.

3 years agoSet Error.sqlcode when unknown codes are received
Daniele Varrazzo [Fri, 11 Feb 2022 19:27:40 +0000 (20:27 +0100)] 
Set Error.sqlcode when unknown codes are received

Close #225.

3 years agoMake the tzdata package a dependency on Windows
Daniele Varrazzo [Wed, 9 Feb 2022 21:03:35 +0000 (22:03 +0100)] 
Make the tzdata package a dependency on Windows

The package replaces the missing system tz database and allows to avoid
the warning and return timestamps in the client timezone instead of in
UTC.

Close #223

3 years agoSet workflows to cancel jobs on the same branch
Daniele Varrazzo [Fri, 11 Feb 2022 00:41:09 +0000 (01:41 +0100)] 
Set workflows to cancel jobs on the same branch

Docs at https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency

3 years agoMerge pull request #224 from The-One-And-Only-H/asyncio-fix
Daniele Varrazzo [Fri, 11 Feb 2022 00:10:36 +0000 (01:10 +0100)] 
Merge pull request #224 from The-One-And-Only-H/asyncio-fix

Fix failures caused by the pytest-asyncio now raising a warning when a sync
function is marked asyncio.

3 years agoMove Windows test to separate file to avoid applying the asyncio mark 224/head
H [Thu, 10 Feb 2022 23:50:41 +0000 (23:50 +0000)] 
Move Windows test to separate file to avoid applying the asyncio mark

3 years agoMake synchronous test async to avoid asyncio error
H [Thu, 10 Feb 2022 23:07:18 +0000 (23:07 +0000)] 
Make synchronous test async to avoid asyncio error

3 years agoConfigure codespell to run on a dirty working directory
Daniele Varrazzo [Sun, 6 Feb 2022 00:24:17 +0000 (01:24 +0100)] 
Configure codespell to run on a dirty working directory

3 years agoAdd doc section about server messages handling
Daniele Varrazzo [Sun, 6 Feb 2022 00:23:09 +0000 (01:23 +0100)] 
Add doc section about server messages handling

3 years agoFix typo/improve errors docs
Daniele Varrazzo [Sat, 5 Feb 2022 22:43:13 +0000 (23:43 +0100)] 
Fix typo/improve errors docs

3 years agoFix docs typo
Daniele Varrazzo [Sat, 5 Feb 2022 22:31:51 +0000 (23:31 +0100)] 
Fix docs typo

3 years agoNote Python 3.6 dropped support in pool release notes
Daniele Varrazzo [Sat, 5 Feb 2022 19:25:02 +0000 (20:25 +0100)] 
Note Python 3.6 dropped support in pool release notes

3 years agoPrepare psycopg_pool 3.1 for release pool-3.1
Daniele Varrazzo [Sat, 5 Feb 2022 15:50:37 +0000 (16:50 +0100)] 
Prepare psycopg_pool 3.1 for release

3 years agoFix typo in prepared statements+pooling warning
Chris Roberts [Fri, 4 Feb 2022 21:52:07 +0000 (15:52 -0600)] 
Fix typo in prepared statements+pooling warning

3 years agoFix pool docs typo
Joe Freeman [Wed, 2 Feb 2022 21:22:35 +0000 (21:22 +0000)] 
Fix pool docs typo

3 years agoMerge branch 'black-stable'
Daniele Varrazzo [Mon, 31 Jan 2022 10:37:10 +0000 (10:37 +0000)] 
Merge branch 'black-stable'

3 years agoApply string manipulations from black --preview
Daniele Varrazzo [Sun, 30 Jan 2022 16:57:45 +0000 (16:57 +0000)] 
Apply string manipulations from black --preview

They are stable under the current black and look an improvement.

3 years agoRestore black max line length to its default
Daniele Varrazzo [Sun, 30 Jan 2022 16:40:19 +0000 (16:40 +0000)] 
Restore black max line length to its default

Trying black --preview, it performs several aggressive changes that are
made worse by the stricter margin, so relax it to the default.

3 years agoMove to using the stable black version 22.1.0
Daniele Varrazzo [Sun, 30 Jan 2022 13:38:47 +0000 (13:38 +0000)] 
Move to using the stable black version 22.1.0

3 years agofix: confusing named parameters in example query
Jules Sagot--Gentil [Sat, 29 Jan 2022 17:25:45 +0000 (18:25 +0100)] 
fix: confusing named parameters in example query

In the named parameters example query, the name of the parameters are
Python built in data types: int and str.

This is confusing because it looks like we are casting values passed
as arguments instead of passing named arguments.

3 years agoFix typo
Benji York [Sat, 22 Jan 2022 14:35:06 +0000 (08:35 -0600)] 
Fix typo

Toilets are not to be taken lightly.

3 years agoTypo fixed
Daniele Varrazzo [Thu, 20 Jan 2022 14:37:13 +0000 (14:37 +0000)] 
Typo fixed

3 years agoMerge pull request #211 from The-One-And-Only-H/codespell
Daniele Varrazzo [Wed, 19 Jan 2022 22:17:44 +0000 (22:17 +0000)] 
Merge pull request #211 from The-One-And-Only-H/codespell

3 years agoAdd codespell to pipeline 211/head
H [Wed, 19 Jan 2022 20:56:18 +0000 (20:56 +0000)] 
Add codespell to pipeline

3 years agoConfigure codespell in tox.ini
H [Wed, 19 Jan 2022 20:57:35 +0000 (20:57 +0000)] 
Configure codespell in tox.ini

3 years agoFix spelling errors found by codespell
H [Wed, 19 Jan 2022 20:57:35 +0000 (20:57 +0000)] 
Fix spelling errors found by codespell

3 years agoRename noe function to no_e
H [Wed, 19 Jan 2022 20:57:34 +0000 (20:57 +0000)] 
Rename noe function to no_e

3 years agoabc.rst: Fix typos discovered by codespell
Christian Clauss [Sun, 16 Jan 2022 09:32:20 +0000 (10:32 +0100)] 
abc.rst: Fix typos discovered by codespell

https://pypi.org/project/codespell/

3 years agoAllow one test to fail on Windows C implementation
Daniele Varrazzo [Fri, 14 Jan 2022 03:44:56 +0000 (04:44 +0100)] 
Allow one test to fail on Windows C implementation

This test doesn't run in tox, so it doesn't benefit from repeats, and it
fails often indeed on flakey tests.

Add pytest option to tolerate a number of failures, and use it.

3 years agoDon't reset the random seed re-running failed tests
Daniele Varrazzo [Fri, 14 Jan 2022 03:17:15 +0000 (04:17 +0100)] 
Don't reset the random seed re-running failed tests

We don't want to make them pass because we didn't like the random draw.
It's not best of three.

3 years agoDrop dataclasses package from constraints file
Daniele Varrazzo [Fri, 14 Jan 2022 01:31:07 +0000 (02:31 +0100)] 
Drop dataclasses package from constraints file

It is part of the stdlib in all supported Python versions, so it is no
more an external dependency.

3 years agoAdd compatibility macro for PQsetTraceFlags
Daniele Varrazzo [Fri, 14 Jan 2022 01:01:48 +0000 (02:01 +0100)] 
Add compatibility macro for PQsetTraceFlags

Avoid a warning of implicit declaration compiling with libpq < 14.

3 years agoFix definitions for pipeline replacements macros
Daniele Varrazzo [Fri, 14 Jan 2022 00:48:12 +0000 (01:48 +0100)] 
Fix definitions for pipeline replacements macros

The previous definition caused a warning for implicit conversion from
void* to int.

3 years agoAllow passing the PIP_CONSTRAINT env var to tox
Daniele Varrazzo [Fri, 14 Jan 2022 01:23:51 +0000 (02:23 +0100)] 
Allow passing the PIP_CONSTRAINT env var to tox

This allows to run tests using the oldest, rather than the newest,
dependency packages, by passing it the tests/constraints.txt file.

3 years agoUse wheel 0.37 as minimum version
Daniele Varrazzo [Fri, 14 Jan 2022 00:07:03 +0000 (01:07 +0100)] 
Use wheel 0.37 as minimum version

It is the first version officially supporting Python 3.10
https://wheel.readthedocs.io/en/stable/news.html

3 years agoDrop explicit tests retries
Daniele Varrazzo [Thu, 13 Jan 2022 21:57:45 +0000 (22:57 +0100)] 
Drop explicit tests retries

Now we just retry all failing tests automatically.

3 years agoRetry automatically flakey tests in tox runs
Daniele Varrazzo [Thu, 13 Jan 2022 21:56:44 +0000 (22:56 +0100)] 
Retry automatically flakey tests in tox runs

3 years agoBump min version required for pytest-asyncio to 0.17.0
Daniele Varrazzo [Thu, 13 Jan 2022 19:00:14 +0000 (20:00 +0100)] 
Bump min version required for pytest-asyncio to 0.17.0

Older versions fail for the presence of asyncio_mode in pytest config,
which is required from 0.17 on instead.

3 years agoConfigure the async loop at test session start
Daniele Varrazzo [Thu, 13 Jan 2022 16:17:37 +0000 (17:17 +0100)] 
Configure the async loop at test session start

Doing it in a fixture is too late: event_loop might have already been
called if the first test running is async, and it would fail on Windows.

This started to be needed after pytest-asyncio 0.17.0 was released.
See <https://github.com/pytest-dev/pytest-asyncio/issues/256>.

3 years agoSet asyncio mode in pytest configuration
Daniele Varrazzo [Thu, 13 Jan 2022 15:17:41 +0000 (16:17 +0100)] 
Set asyncio mode in pytest configuration

Remove the warning raised in pytest-async >= 0.17.0 if the setting is
missing.

3 years agoMerge branch 'null-pool'
Daniele Varrazzo [Thu, 13 Jan 2022 14:07:52 +0000 (15:07 +0100)] 
Merge branch 'null-pool'

3 years agoMore robust null pool tests
Daniele Varrazzo [Sat, 8 Jan 2022 18:37:14 +0000 (19:37 +0100)] 
More robust null pool tests

Fix race conditions of tasks completing before a concurrent client is
queued.

Fix test relying on fixed broken behaviour of copy().

Use connection.info rather than connection.pgconn to obtain higher level
results (e.g. Enum instead of int).

3 years agoRefactor pools to reduce code duplication
Daniele Varrazzo [Sat, 8 Jan 2022 17:35:41 +0000 (18:35 +0100)] 
Refactor pools to reduce code duplication

Use common getconn/putconn implementations and implement only the
different behaviours in subclasses.

3 years agoAdd null-pools documentation
Daniele Varrazzo [Thu, 6 Jan 2022 02:39:42 +0000 (03:39 +0100)] 
Add null-pools documentation

3 years agoAdd NullPool and AsyncNullPool
Daniele Varrazzo [Mon, 3 Jan 2022 19:20:29 +0000 (20:20 +0100)] 
Add NullPool and AsyncNullPool

Close #148

3 years agoMinor changes to pool docs
Daniele Varrazzo [Sun, 9 Jan 2022 17:46:58 +0000 (18:46 +0100)] 
Minor changes to pool docs

3 years agoImprove pool docs, especially pools and connections life cycle
Daniele Varrazzo [Sun, 9 Jan 2022 14:04:55 +0000 (15:04 +0100)] 
Improve pool docs, especially pools and connections life cycle

3 years agoAdd wait parameter to pool.open()
Daniele Varrazzo [Sun, 9 Jan 2022 13:14:14 +0000 (14:14 +0100)] 
Add wait parameter to pool.open()

3 years agoRelax some timing tests tolerances
Daniele Varrazzo [Sat, 8 Jan 2022 22:37:55 +0000 (23:37 +0100)] 
Relax some timing tests tolerances

Seeing them failing regularly in Github workflows.

3 years agoDrop support for Python 3.6
Daniele Varrazzo [Sat, 8 Jan 2022 20:57:14 +0000 (21:57 +0100)] 
Drop support for Python 3.6

3 years agoBump version numbers for release
Daniele Varrazzo [Sat, 8 Jan 2022 18:57:04 +0000 (19:57 +0100)] 
Bump version numbers for release

3 years agoLeave start year only in docs footer
Daniele Varrazzo [Sat, 8 Jan 2022 01:16:57 +0000 (02:16 +0100)] 
Leave start year only in docs footer

3 years agoUpdate, once and for good, the copyright year
Daniele Varrazzo [Sat, 8 Jan 2022 01:09:05 +0000 (02:09 +0100)] 
Update, once and for good, the copyright year

After getting more information about the matter and having convinced
myself that there is no need, except FOMO, to extend the copyright year
on source code, change all our entries to leave only the start year.

    git ls-tree -r HEAD --name-only \
        | xargs sed -i '/Copyright.*\(Varrazzo\|Psycopg\)/ s/-20..//'

3 years agoDon't leave the connection ACTIVE on error in COPY_OUT
Daniele Varrazzo [Fri, 7 Jan 2022 21:06:20 +0000 (22:06 +0100)] 
Don't leave the connection ACTIVE on error in COPY_OUT

Cancel the active COPY operation if the server has not finished sending
the data yet.

Close #203.

Also fix the tests which were based on this broken behaviour. A case of
self-administered Hyrum's law.

3 years agoUse info instead of pgconn in copy tests
Daniele Varrazzo [Fri, 7 Jan 2022 21:05:02 +0000 (22:05 +0100)] 
Use info instead of pgconn in copy tests

It displays better information in case of assert failed.

3 years agoAdd prepare_threshold connection parameter
Daniele Varrazzo [Fri, 7 Jan 2022 01:07:02 +0000 (02:07 +0100)] 
Add prepare_threshold connection parameter

This can help configuring connections to use PgBouncer. It is possible
to use the attribute in the pool kwargs, for instance, instead of using
the more complex configure callback.

Close #200.

3 years agoExclude mypy 0.931 too from tests
Daniele Varrazzo [Fri, 7 Jan 2022 18:35:03 +0000 (19:35 +0100)] 
Exclude mypy 0.931 too from tests

It seems still affected by https://github.com/python/mypy/issues/11820.

3 years agoDon't overwrite the module of the psycopg.pq.pq_ctypes objects
Daniele Varrazzo [Fri, 7 Jan 2022 17:32:47 +0000 (18:32 +0100)] 
Don't overwrite the module of the psycopg.pq.pq_ctypes objects

It might be useful to tell apart the C version from the python versions
for debugging. The C versions don't do it, so they repr as:

    <psycopg_binary.pq.PGconn [IDLE] (database=piro) at 0x7f8556deb040>

See #201.

3 years agoAdd example about DDL statement with quoted parameter
Daniele Varrazzo [Fri, 7 Jan 2022 01:54:25 +0000 (02:54 +0100)] 
Add example about DDL statement with quoted parameter

See #199.

3 years agoAdd mark for pool tests
Daniele Varrazzo [Thu, 6 Jan 2022 23:23:46 +0000 (00:23 +0100)] 
Add mark for pool tests

Don't auto-skip pool test if import fails. This would miss serious
problems leading to the pool not being importable. If someone wants to
skip the pool tests they can use `-m 'not pool'` now.

3 years agoDrop broken test about setting prepare attributes on the class
Daniele Varrazzo [Fri, 7 Jan 2022 01:11:29 +0000 (02:11 +0100)] 
Drop broken test about setting prepare attributes on the class

I'm just clobbering the property here. It doesn't work. Thankfully it
wasn't documented to work...

3 years agoDon't look up other modules objects in __del__ methods
Daniele Varrazzo [Thu, 6 Jan 2022 16:09:22 +0000 (17:09 +0100)] 
Don't look up other modules objects in __del__ methods

The modules might have been already cleaned up during interpreted
shutdown. See <https://bugs.python.org/issue46256#msg409847> for an
explanation.

The stdlib guards against the same thing happening too. However they
take a reference in the function closure, which is stronger than what we
do. Doing so, on our strictly typed codebase, is a tedious chore, so, if
this is enough (it should be, according to the OP), I'm happy this way.

Close #198.

3 years agoAllow pools to have min_size = 0 as long as they can grow
Daniele Varrazzo [Thu, 6 Jan 2022 21:16:09 +0000 (22:16 +0100)] 
Allow pools to have min_size = 0 as long as they can grow

Add tests to verify they can grow from 0 no problem.

3 years agoAdd ConnectionTimeout subclass of OperationalError
Daniele Varrazzo [Wed, 5 Jan 2022 01:50:25 +0000 (02:50 +0100)] 
Add ConnectionTimeout subclass of OperationalError

To be used in the connection pool to detect timeout on connection.

Backported to Psycopg 3.0.8 to allow the pool 3.1 to work with it, at
least on diminished capacity (NullPool.connection() would time out only
for clients in the queue, not in case of new connection timeout).

3 years agoMerge branch 'pool-checks'
Daniele Varrazzo [Wed, 5 Jan 2022 22:13:52 +0000 (23:13 +0100)] 
Merge branch 'pool-checks'

3 years agoRaise PoolClosed on wait() on a closed pool
Daniele Varrazzo [Wed, 5 Jan 2022 02:24:52 +0000 (03:24 +0100)] 
Raise PoolClosed on wait() on a closed pool

Previously it might have raised an assert, if, for instance, wait would
have failed and retried.

3 years agoRaise ValueError if the pool min_size is <= 0
Daniele Varrazzo [Mon, 3 Jan 2022 18:52:44 +0000 (19:52 +0100)] 
Raise ValueError if the pool min_size is <= 0

Before it would have created a broken pool, blocking forever on getconn.

3 years agoMove some common checks to the pool base class
Daniele Varrazzo [Mon, 3 Jan 2022 18:40:11 +0000 (19:40 +0100)] 
Move some common checks to the pool base class

3 years agoUse caplog.set_level instead of manual filtering in tests
Daniele Varrazzo [Wed, 5 Jan 2022 19:23:25 +0000 (20:23 +0100)] 
Use caplog.set_level instead of manual filtering in tests

3 years agoSkip tests using the deaf_port fixture on macOS and Windows
Daniele Varrazzo [Wed, 5 Jan 2022 20:52:55 +0000 (21:52 +0100)] 
Skip tests using the deaf_port fixture on macOS and Windows

They fail some 50% of the time, looks like the port is not really
listening, the fact that the function is called listen() is just a
practical joke.

https://github.com/psycopg/psycopg/runs/4719288041?check_suite_focus=true

3 years agoAdd deaf_port fixture and base timeout tests on it
Daniele Varrazzo [Wed, 5 Jan 2022 00:53:07 +0000 (01:53 +0100)] 
Add deaf_port fixture and base timeout tests on it

3 years agoMerge branch 'pool-open'
Daniele Varrazzo [Mon, 3 Jan 2022 18:47:38 +0000 (19:47 +0100)] 
Merge branch 'pool-open'

3 years agoUse the present tense in PoolClosed error messages 196/head
Daniele Varrazzo [Mon, 3 Jan 2022 15:59:29 +0000 (16:59 +0100)] 
Use the present tense in PoolClosed error messages

Thank you John Aldis! https://twitter.com/johnaldis/status/1478016200634425348