]> git.ipfire.org Git - thirdparty/psycopg.git/log
thirdparty/psycopg.git
17 months agodocs: mention musl-ctypes workaround in news file 725/head
Daniele Varrazzo [Mon, 29 Jan 2024 00:24:05 +0000 (00:24 +0000)] 
docs: mention musl-ctypes workaround in news file

17 months agofix: add `libc.so` fallback for musl systems to the ctypes impl
Michał Górny [Sat, 27 Jan 2024 14:28:34 +0000 (15:28 +0100)] 
fix: add `libc.so` fallback for musl systems to the ctypes impl

Add a fallback to `libc.so` library name to fix loading the ctypes
implementation on musl systems.  On musl, `find_library("c")` does
not work (the problem has been reported to CPython in 2014, and has not
been resolved yet), causing the module to fail on `assert libcname`.
Instead, add a fallback to using `libc.so` and let ctypes raise
an exception if such a library does not exist.

17 months agotest: drop ineffective marker on fixture
Daniele Varrazzo [Mon, 29 Jan 2024 00:08:47 +0000 (00:08 +0000)] 
test: drop ineffective marker on fixture

Previously ignored, it has become an error in PyTest 8.

17 months agoMerge branch 'no-conn-composible'
Daniele Varrazzo [Sat, 27 Jan 2024 02:57:18 +0000 (02:57 +0000)] 
Merge branch 'no-conn-composible'

17 months agofeat: allow no connection parameter in sql.Composible.as_string()/as_bytes()
Daniele Varrazzo [Fri, 19 Jan 2024 16:40:37 +0000 (17:40 +0100)] 
feat: allow no connection parameter in sql.Composible.as_string()/as_bytes()

Close #716

17 months agofeat: allow Identifier.as_string() and as_bytes() to take no connection
Daniele Varrazzo [Fri, 12 Jan 2024 16:57:42 +0000 (17:57 +0100)] 
feat: allow Identifier.as_string() and as_bytes() to take no connection

17 months agoMerge pull request #720 from enapupe/fix-interval-overflow
Daniele Varrazzo [Sat, 27 Jan 2024 02:05:24 +0000 (02:05 +0000)] 
Merge pull request #720 from enapupe/fix-interval-overflow

fix: use long for seconds to prevent IntervalLoader from overflowing

17 months agodocs: add release note about interval overflow fix 720/head
Daniele Varrazzo [Sat, 27 Jan 2024 01:29:32 +0000 (01:29 +0000)] 
docs: add release note about interval overflow fix

17 months agofix(c): don't overflow intervals on windows either
Daniele Varrazzo [Sat, 27 Jan 2024 01:09:11 +0000 (01:09 +0000)] 
fix(c): don't overflow intervals on windows either

In MSVC, long is 4 bytes. Should use long long instead. int64_t is more
understandable.

17 months agofix(c): use long for seconds to prevent IntervalLoader from overflowing
Iacami Gevaerd [Tue, 16 Jan 2024 15:13:01 +0000 (12:13 -0300)] 
fix(c): use long for seconds to prevent IntervalLoader from overflowing

if the given interval is too long for a regular int it will become
negative an cause inconsistencies with the regular python implementation

17 months agochore: bump black to 24.1.0
Daniele Varrazzo [Fri, 26 Jan 2024 23:44:49 +0000 (23:44 +0000)] 
chore: bump black to 24.1.0

17 months agoMerge branch 'fix-deadlock-on-pipeline-exit'
Daniele Varrazzo [Fri, 26 Jan 2024 23:53:24 +0000 (23:53 +0000)] 
Merge branch 'fix-deadlock-on-pipeline-exit'

17 months agofix: force a sync exiting the pipeline mode
Daniele Varrazzo [Fri, 26 Jan 2024 00:29:29 +0000 (00:29 +0000)] 
fix: force a sync exiting the pipeline mode

Without it there may be a deadlock and we would be waiting to fetch a
result that will never come.

Close #685.

18 months agofeat: add ConnDict, ConnParam to abc module
Daniele Varrazzo [Mon, 8 Jan 2024 12:22:55 +0000 (13:22 +0100)] 
feat: add ConnDict, ConnParam to abc module

Formalize the type of parameter to pass to the libq.

ConnMapping is required when a covariant type is needed.

18 months agorefactor: move TypeAlias back to _compat module
Daniele Varrazzo [Mon, 8 Jan 2024 11:48:22 +0000 (12:48 +0100)] 
refactor: move TypeAlias back to _compat module

It was imported directly by typing_extensions to work around
https://github.com/microsoft/pyright/issues/4197
but the issue has been fixed in pyright 1.1.297, released almost one
year ago.

18 months agochore: bump psycopg_pool package version to 3.2.1
Daniele Varrazzo [Sun, 7 Jan 2024 01:42:03 +0000 (02:42 +0100)] 
chore: bump psycopg_pool package version to 3.2.1

18 months agochore: bump psycopg package version to 3.1.17
Daniele Varrazzo [Sun, 7 Jan 2024 01:41:20 +0000 (02:41 +0100)] 
chore: bump psycopg package version to 3.1.17

18 months agoci: revert upload action to v3
Daniele Varrazzo [Sun, 7 Jan 2024 11:49:41 +0000 (12:49 +0100)] 
ci: revert upload action to v3

v4 requires to have every uploaded artifact in a separate directory.

- https://github.com/actions/upload-artifact/issues/478
- https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md

18 months agochore(c): add missing enum entries
Daniele Varrazzo [Sat, 6 Jan 2024 19:37:37 +0000 (20:37 +0100)] 
chore(c): add missing enum entries

18 months agodocs: add note about checking enums and docs on PostgreSQL update
Daniele Varrazzo [Sat, 6 Jan 2024 19:36:56 +0000 (20:36 +0100)] 
docs: add note about checking enums and docs on PostgreSQL update

18 months agoMerge branch 'fix-699-master'
Daniele Varrazzo [Sat, 6 Jan 2024 19:50:24 +0000 (20:50 +0100)] 
Merge branch 'fix-699-master'

18 months agorefactor: generate conninfo attempts from async counterpart
Daniele Varrazzo [Sat, 6 Jan 2024 17:06:54 +0000 (18:06 +0100)] 
refactor: generate conninfo attempts from async counterpart

18 months agofix: perform multiple attemps if a host name resolve to multiple hosts
Daniele Varrazzo [Sat, 6 Jan 2024 16:24:48 +0000 (17:24 +0100)] 
fix: perform multiple attemps if a host name resolve to multiple hosts

We now perform DNS resolution in Python both in the sync and async code.
Because the two code paths are now very similar, make sure they pass the
same tests.

Close #699.

18 months agorefactor(test): make resolution monkeypatching common fixtures
Daniele Varrazzo [Sat, 6 Jan 2024 16:10:58 +0000 (17:10 +0100)] 
refactor(test): make resolution monkeypatching common fixtures

18 months agorefactor: separate ConnectionInfo object from conninfo module
Daniele Varrazzo [Sat, 6 Jan 2024 14:50:14 +0000 (15:50 +0100)] 
refactor: separate ConnectionInfo object from conninfo module

It was there just because the name is similar, but its purpose is
entirely different.

18 months agostyle: drop unneeded function definition split
Daniele Varrazzo [Sat, 6 Jan 2024 12:50:05 +0000 (13:50 +0100)] 
style: drop unneeded function definition split

18 months agochore: upload github actions dependencies
Daniele Varrazzo [Tue, 2 Jan 2024 03:29:48 +0000 (04:29 +0100)] 
chore: upload github actions dependencies

18 months agoMerge branch 'fix-709'
Daniele Varrazzo [Sat, 6 Jan 2024 12:11:50 +0000 (13:11 +0100)] 
Merge branch 'fix-709'

18 months agorefactor(pool): rename ConnectionAttempt as AttemptWithBackoff
Daniele Varrazzo [Fri, 29 Dec 2023 23:49:28 +0000 (00:49 +0100)] 
refactor(pool): rename ConnectionAttempt as AttemptWithBackoff

This class implements the backoff + jitter policy and is now used to
repeat checks too.

18 months agofix(pool): use an exponential backoff to separate failing checks
Daniele Varrazzo [Fri, 29 Dec 2023 23:41:07 +0000 (00:41 +0100)] 
fix(pool): use an exponential backoff to separate failing checks

This is a consistent behaviour with with the exponential backoff used in
reconnection attempts, and actually we could reuse the same object
implementing the backoff + jitter.

See also #709

18 months agofix(pool): respect timeout on getconn() when the check function fails
Daniele Varrazzo [Fri, 29 Dec 2023 13:15:07 +0000 (14:15 +0100)] 
fix(pool): respect timeout on getconn() when the check function fails

Close #709.

18 months agoMerge branch 'fix-308'
Daniele Varrazzo [Sat, 6 Jan 2024 11:19:58 +0000 (12:19 +0100)] 
Merge branch 'fix-308'

18 months agorefactor(pool): avoid constructor overloading by using generic default
Daniele Varrazzo [Wed, 3 Jan 2024 01:32:28 +0000 (02:32 +0100)] 
refactor(pool): avoid constructor overloading by using generic default

18 months agorefactor: drop overloading of the Connection.connect() function
Daniele Varrazzo [Wed, 3 Jan 2024 01:14:46 +0000 (02:14 +0100)] 
refactor: drop overloading of the Connection.connect() function

The default for the Row TypeVar makes it redundant.

18 months agofix: define the Row TypeVar as defaulting to TupleRow
Daniele Varrazzo [Wed, 3 Jan 2024 00:44:22 +0000 (01:44 +0100)] 
fix: define the Row TypeVar as defaulting to TupleRow

This allows to return `Self` uniformly from the `Connection.connect()` class
method, which in turns allows to subclass the connection without the
need of redefining the complex signature.

Close #308

18 months agorefactor: use TypeVar from typing_extension
Daniele Varrazzo [Wed, 3 Jan 2024 00:33:35 +0000 (01:33 +0100)] 
refactor: use TypeVar from typing_extension

This includes the default parameter, which should fix the problem of the
awkward definition of Row defaulting to TupleRow.

18 months agorefactor: use Self to represent the return from `BaseConnection._connect_gen()`
Daniele Varrazzo [Wed, 3 Jan 2024 00:59:30 +0000 (01:59 +0100)] 
refactor: use Self to represent the return from `BaseConnection._connect_gen()`

18 months agochore: drop unneeded type annotations on self
Daniele Varrazzo [Wed, 3 Jan 2024 02:07:27 +0000 (03:07 +0100)] 
chore: drop unneeded type annotations on self

18 months agorefactor: use typing.Self
Daniele Varrazzo [Sat, 30 Dec 2023 00:30:39 +0000 (01:30 +0100)] 
refactor: use typing.Self

The object seems available for all the supported Python version and
should avoid problems with PyRight (see #708).

It is not a solution for #308 because we cannot use `Self[Row]`.

18 months agotest: add async driver to sqlalchemy pipeline
Federico Caselli [Mon, 18 Dec 2023 20:31:22 +0000 (21:31 +0100)] 
test: add async driver to sqlalchemy pipeline

18 months agochore: bump psycopg package version to 3.1.16
Daniele Varrazzo [Tue, 19 Dec 2023 01:07:54 +0000 (02:07 +0100)] 
chore: bump psycopg package version to 3.1.16

18 months agofix: fix empty ports handling in async multiple connection attempts
Daniele Varrazzo [Mon, 18 Dec 2023 23:58:35 +0000 (00:58 +0100)] 
fix: fix empty ports handling in async multiple connection attempts

Close #703.

18 months agochore: bump ast_commment version
Daniele Varrazzo [Mon, 18 Dec 2023 22:33:12 +0000 (23:33 +0100)] 
chore: bump ast_commment version

Drop workarounds for a couple of bugs which have been fixed upstream.

Force re-generation of the docker image when the ast_comment module changes.

18 months agodocs: improvement to the Cursor docs
Daniele Varrazzo [Mon, 18 Dec 2023 01:26:49 +0000 (02:26 +0100)] 
docs: improvement to the Cursor docs

18 months agodocs: add section about concurrency
Daniele Varrazzo [Mon, 18 Dec 2023 01:23:52 +0000 (02:23 +0100)] 
docs: add section about concurrency

18 months agochore: include codespell in dev dependencies
Daniele Varrazzo [Mon, 18 Dec 2023 01:54:26 +0000 (02:54 +0100)] 
chore: include codespell in dev dependencies

18 months agochore: bump psycopg package version to 3.1.15
Daniele Varrazzo [Thu, 14 Dec 2023 03:26:56 +0000 (04:26 +0100)] 
chore: bump psycopg package version to 3.1.15

18 months agoMerge branch 'fix-service-file'
Daniele Varrazzo [Thu, 14 Dec 2023 12:51:23 +0000 (13:51 +0100)] 
Merge branch 'fix-service-file'

18 months agorefactor: add compiled_default option to _get_params
Daniele Varrazzo [Wed, 13 Dec 2023 13:20:49 +0000 (14:20 +0100)] 
refactor: add compiled_default option to _get_params

Make it less awkward to come out with a 5432 when we really want a port
number (in name resolution) but still allow to leave it unspecified to
avoid mangling the conninfo.

18 months agofix: honour the PGLOADBALANCEHOSTS env var
Daniele Varrazzo [Wed, 13 Dec 2023 11:31:13 +0000 (12:31 +0100)] 
fix: honour the PGLOADBALANCEHOSTS env var

18 months agofix: honour the PGCONNECT_TIMEOUT env var
Daniele Varrazzo [Wed, 13 Dec 2023 03:55:51 +0000 (04:55 +0100)] 
fix: honour the PGCONNECT_TIMEOUT env var

18 months agofix: set minimum timeout to 2s
Daniele Varrazzo [Wed, 13 Dec 2023 03:35:48 +0000 (04:35 +0100)] 
fix: set minimum timeout to 2s

This is consistent with what the libpq does.

Move timeout calculation to a function in conninfo module and don't
change the connect_timeout parameter explicitly in the connection
string.

Drop awful drop_default_args_from_conninfo() from tests.

18 months agofix: add debug logging when a connection attempt is discarded
Daniele Varrazzo [Wed, 13 Dec 2023 03:34:40 +0000 (04:34 +0100)] 
fix: add debug logging when a connection attempt is discarded

18 months agorefactor: return lists from conninfo attempt functions
Daniele Varrazzo [Wed, 13 Dec 2023 00:33:04 +0000 (01:33 +0100)] 
refactor: return lists from conninfo attempt functions

18 months agofix: shuffle attempts when one host resolves to more than one IP
Daniele Varrazzo [Wed, 13 Dec 2023 00:03:55 +0000 (01:03 +0100)] 
fix: shuffle attempts when one host resolves to more than one IP

This behaviour (first resolve all the hosts, then shuffle the IPs) mimics
better what the libpq does in non-async mode.

18 months agofix: don't add defaults to connection strings
Daniele Varrazzo [Tue, 12 Dec 2023 19:33:20 +0000 (20:33 +0100)] 
fix: don't add defaults to connection strings

A default such as empty string for host may may shadow values defined in
a service file.

Fix #694.

19 months agofix: fix iteration resolving hosts with multiple IP addresses in async mode
Daniele Varrazzo [Tue, 12 Dec 2023 16:56:37 +0000 (17:56 +0100)] 
fix: fix iteration resolving hosts with multiple IP addresses in async mode

Fix #695 (not 100% sure, but probably).

19 months agotest: mark a couple of test slow
Daniele Varrazzo [Tue, 12 Dec 2023 17:02:22 +0000 (18:02 +0100)] 
test: mark a couple of test slow

Sub-second, but noticeable glitches in my stream of green dots.

19 months agotest: mark flaky ref count tests
nialov [Mon, 4 Dec 2023 17:33:46 +0000 (19:33 +0200)] 
test: mark flaky ref count tests

All tests that have the 'gc' fixture are now marked with the refcount mark. The
reasoning is that they demonstrate flaky behaviour and disabling them in
certain CI is necessary to ensure reliable testing. See #692

19 months agodocs: fix doc about the module gevent needs to patch
Daniele Varrazzo [Mon, 4 Dec 2023 09:35:40 +0000 (10:35 +0100)] 
docs: fix doc about the module gevent needs to patch

19 months agochore: bump psycopg package version to 3.1.14
Daniele Varrazzo [Sat, 2 Dec 2023 02:20:04 +0000 (03:20 +0100)] 
chore: bump psycopg package version to 3.1.14

19 months agoMerge branch 'pypy'
Daniele Varrazzo [Sat, 2 Dec 2023 02:19:20 +0000 (03:19 +0100)] 
Merge branch 'pypy'

19 months agotest: add gc fixtures to skip tests on PyPy more easily 686/head
Nick Pope [Tue, 28 Nov 2023 15:50:30 +0000 (15:50 +0000)] 
test: add gc fixtures to skip tests on PyPy more easily

19 months agochore: add support for PyPy.
Nick Pope [Tue, 28 Nov 2023 12:46:59 +0000 (12:46 +0000)] 
chore: add support for PyPy.

19 months agoMerge branch 'fix-gevent'
Daniele Varrazzo [Fri, 1 Dec 2023 23:40:07 +0000 (00:40 +0100)] 
Merge branch 'fix-gevent'

19 months agoci: test gevent integration 688/head
Daniele Varrazzo [Thu, 30 Nov 2023 10:23:27 +0000 (11:23 +0100)] 
ci: test gevent integration

19 months agofix: ensure gevent collaboration
Daniele Varrazzo [Thu, 30 Nov 2023 09:05:33 +0000 (10:05 +0100)] 
fix: ensure gevent collaboration

Close #527

19 months agotest: let pytest show more info in summary
Denis Laxalde [Thu, 30 Nov 2023 20:01:01 +0000 (21:01 +0100)] 
test: let pytest show more info in summary

We add '-ra' to pytest options so as to get report about "(a)ll except
passed" tests. This is in particular useful to get the detailed message
about why some tests got skipped (especially useful in CI).

19 months agorefactor: use `yield from` in connections attempts
Daniele Varrazzo [Thu, 30 Nov 2023 09:11:46 +0000 (10:11 +0100)] 
refactor: use `yield from` in connections attempts

19 months agoMerge pull request #682 from mweinelt/clear-pg-env-when-testing-connect
Daniele Varrazzo [Tue, 21 Nov 2023 12:19:25 +0000 (12:19 +0000)] 
Merge pull request #682 from mweinelt/clear-pg-env-when-testing-connect

19 months agotest: fix test failing to connect if env vars are cleaned 682/head
Daniele Varrazzo [Tue, 21 Nov 2023 08:49:24 +0000 (09:49 +0100)] 
test: fix test failing to connect if env vars are cleaned

Add `dsn_env` fixture returning the `dsn` merged with the values in the
PG* env vars. This way the env can be cleaned but a working connection
string is still available.

19 months agofix: flush PG environment variables in test_connect{,_args}
Martin Weinelt [Tue, 21 Nov 2023 01:55:02 +0000 (02:55 +0100)] 
fix: flush PG environment variables in test_connect{,_args}

These tests were previously affected by environment variables, that can
be used to configure a postgresql instance.

Closes: #681
19 months agotest: allow importing the tests module on master with Psycopg 3.1
Daniele Varrazzo [Sun, 19 Nov 2023 12:36:16 +0000 (13:36 +0100)] 
test: allow importing the tests module on master with Psycopg 3.1

Useful to test the master version of the pool with a released version of
psycopg.

19 months agochore(ci): use existing macos11 packages in macOS arm build
Daniele Varrazzo [Fri, 17 Nov 2023 16:00:08 +0000 (17:00 +0100)] 
chore(ci): use existing macos11 packages in macOS arm build

19 months agochore: bump psycopg package version to 3.1.13
Daniele Varrazzo [Fri, 17 Nov 2023 15:36:57 +0000 (16:36 +0100)] 
chore: bump psycopg package version to 3.1.13

19 months agofix: plug memory leak receiving notifications in python libpq wrapper
Daniele Varrazzo [Thu, 16 Nov 2023 01:27:14 +0000 (02:27 +0100)] 
fix: plug memory leak receiving notifications in python libpq wrapper

Close #679.

19 months agoMerge pull request #675 from psycopg/fix-multiple-hosts
Daniele Varrazzo [Tue, 14 Nov 2023 00:22:12 +0000 (00:22 +0000)] 
Merge pull request #675 from psycopg/fix-multiple-hosts

Fix handling of multiple hosts

19 months agochore: drop conninfo.resolve_hostaddr_async 675/head
Daniele Varrazzo [Mon, 13 Nov 2023 22:56:46 +0000 (23:56 +0100)] 
chore: drop conninfo.resolve_hostaddr_async

The function is no more used internally and only exposed from the _dns
module with a warning. Its implementation is now an application of a few
internal functions exposed internally by the conninfo module. Move the
whole implementation into _dns.

19 months agofix: add support for the 'load_balance_hosts' connection parameter
Daniele Varrazzo [Mon, 13 Nov 2023 20:12:45 +0000 (20:12 +0000)] 
fix: add support for the 'load_balance_hosts' connection parameter

19 months agotest: test conninfo attempts functions and multiple host support in connection
Daniele Varrazzo [Mon, 13 Nov 2023 18:08:51 +0000 (18:08 +0000)] 
test: test conninfo attempts functions and multiple host support in connection

19 months agofeat: explicitly iterate on multiple hosts on connections
Daniele Varrazzo [Thu, 26 Oct 2023 21:16:01 +0000 (23:16 +0200)] 
feat: explicitly iterate on multiple hosts on connections

The libpq async connection path doesn't iterate on the attempts, so we
need to do it ourselves.

20 months agorefactor: introduce support function to split connection attempts
Daniele Varrazzo [Thu, 26 Oct 2023 16:28:17 +0000 (18:28 +0200)] 
refactor: introduce support function to split connection attempts

Refactor the `resolve_hostaddr_async()` function to make use of such
facilities.

20 months agorefactor: move setting autocommit on connection out of _connect_gen
Daniele Varrazzo [Wed, 25 Oct 2023 18:23:08 +0000 (20:23 +0200)] 
refactor: move setting autocommit on connection out of _connect_gen

20 months agochore: refresh 3rd party tests
Daniele Varrazzo [Sat, 11 Nov 2023 15:32:07 +0000 (15:32 +0000)] 
chore: refresh 3rd party tests

- upgrade Python to 3.12
- test stable version of SQLAlchemy 2
- add missing SQLAlchemy test dependency

Testing Django with Python 3.12 not enabled yet as it requires pylibmc wheel
packages for Python 3.12 (https://github.com/lericson/pylibmc/issues/288).

20 months agodocs(pool): document 3.1.9 as released
Daniele Varrazzo [Sat, 11 Nov 2023 19:09:30 +0000 (19:09 +0000)] 
docs(pool): document 3.1.9 as released

Packages being baked now.

20 months agoMerge branch 'test-pool-3.2-psycopg-3.1'
Daniele Varrazzo [Sat, 11 Nov 2023 19:09:00 +0000 (19:09 +0000)] 
Merge branch 'test-pool-3.2-psycopg-3.1'

20 months agoci: test psycopg pool package with released a psycopg version
Daniele Varrazzo [Sat, 11 Nov 2023 16:50:42 +0000 (16:50 +0000)] 
ci: test psycopg pool package with released a psycopg version

20 months agotest: allow to run pytest -m pool with psycopg 3.1 imported
Daniele Varrazzo [Sat, 11 Nov 2023 16:47:35 +0000 (16:47 +0000)] 
test: allow to run pytest -m pool with psycopg 3.1 imported

This allows to test psycopg pool 3.2 tests with psycopg 3.1 installed.

20 months agochore: bump psycopg_pool package version to 3.3.0.dev1
Daniele Varrazzo [Sat, 11 Nov 2023 16:57:17 +0000 (16:57 +0000)] 
chore: bump psycopg_pool package version to 3.3.0.dev1

20 months agochore: fix mypy >= 1.7 warning in tests
Daniele Varrazzo [Sat, 11 Nov 2023 15:30:55 +0000 (15:30 +0000)] 
chore: fix mypy >= 1.7 warning in tests

20 months agochore: bump psycopg_pool package version to 3.2.0 pool-3.2.0
Daniele Varrazzo [Sat, 11 Nov 2023 14:59:49 +0000 (14:59 +0000)] 
chore: bump psycopg_pool package version to 3.2.0

20 months agofix(bump_version): fix bumping minor version with dev releases
Daniele Varrazzo [Sat, 11 Nov 2023 14:59:09 +0000 (14:59 +0000)] 
fix(bump_version): fix bumping minor version with dev releases

20 months agochore(macos): build images with more recent Python versions
Daniele Varrazzo [Thu, 2 Nov 2023 09:25:18 +0000 (10:25 +0100)] 
chore(macos): build images with more recent Python versions

20 months agoMerge pull request #670 from psycopg/fix-667
Daniele Varrazzo [Tue, 24 Oct 2023 18:14:59 +0000 (19:14 +0100)] 
Merge pull request #670 from psycopg/fix-667

Handle gracefully EINTR on signals instead of raising InterruptedError

20 months agofix: retry automatically syscall in wait_c if it fails with EINTR 670/head
Daniele Varrazzo [Tue, 24 Oct 2023 09:19:36 +0000 (11:19 +0200)] 
fix: retry automatically syscall in wait_c if it fails with EINTR

Fix #667

20 months agotest: add test to generate an EINTR in wait_c
Daniele Varrazzo [Tue, 24 Oct 2023 08:50:40 +0000 (10:50 +0200)] 
test: add test to generate an EINTR in wait_c

20 months agoMark test_identify_closure as timing-sensitive
Martin Weinelt [Mon, 23 Oct 2023 22:54:18 +0000 (00:54 +0200)] 
Mark test_identify_closure as timing-sensitive

```
____________________________ test_identify_closure _____________________________

conn_cls = <class 'psycopg.Connection'>, dsn = 'host=127.0.0.1 user=psycopg'

    @pytest.mark.crdb_skip("pg_terminate_backend")
    @pytest.mark.slow
    def test_identify_closure(conn_cls, dsn):
        def closer():
            time.sleep(0.2)
            conn2.execute("select pg_terminate_backend(%s)", [conn.pgconn.backend_pid])

        conn = conn_cls.connect(dsn)
        conn2 = conn_cls.connect(dsn)
        try:
            t = threading.Thread(target=closer)
            t.start()
            t0 = time.time()
            try:
                with pytest.raises(psycopg.OperationalError):
                    conn.execute("select pg_sleep(1.0)")
                t1 = time.time()
>               assert 0.2 < t1 - t0 < 0.4
E               assert 0.2 < (1697715164.8614173 - 1697715164.6617775)

tests/test_concurrency.py:231: AssertionError
```

20 months agochore: use AnyIO 4.0+ in tests dependencies
Denis Laxalde [Wed, 18 Oct 2023 08:35:50 +0000 (10:35 +0200)] 
chore: use AnyIO 4.0+ in tests dependencies

We set the 'loop_factory' asyncio option for parametrizing the
anyio_backend() fixture as anyio 4.0 has replaced the 'policy' option by
'loop_factory'.

In tests/pool/test_pool_async_noasyncio.py, we previously used
the anyio_backend_options fixture to retrieve the loop policy; now we
build it directly. This could be improved by using the loop_factory, but
only from Python 3.11 with an asyncio.Runner().

20 months agorefactor(pool): more logical ordering for kwargs
Daniele Varrazzo [Sat, 14 Oct 2023 07:59:57 +0000 (09:59 +0200)] 
refactor(pool): more logical ordering for kwargs

- conn construction params (class, kwargs, the class affects the pool
  type annotations so first is better);
- sizing (documented as an important parameter for the pool);
- open?
- callbacks (in the order they are used);
- name;
- other details more unlikely to be touched.

The order is the same in docs and code.

20 months agoMerge branch 'pool-getconn-safe'
Daniele Varrazzo [Sat, 14 Oct 2023 07:45:52 +0000 (09:45 +0200)] 
Merge branch 'pool-getconn-safe'