]>
git.ipfire.org Git - thirdparty/psycopg.git/log
Nick Pope [Tue, 28 Nov 2023 15:50:30 +0000 (15:50 +0000)]
test: add gc fixtures to skip tests on PyPy more easily
Nick Pope [Tue, 28 Nov 2023 12:46:59 +0000 (12:46 +0000)]
chore: add support for PyPy.
Daniele Varrazzo [Fri, 1 Dec 2023 23:40:07 +0000 (00:40 +0100)]
Merge branch 'fix-gevent'
Daniele Varrazzo [Thu, 30 Nov 2023 10:23:27 +0000 (11:23 +0100)]
ci: test gevent integration
Daniele Varrazzo [Thu, 30 Nov 2023 09:05:33 +0000 (10:05 +0100)]
fix: ensure gevent collaboration
Close #527
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).
Daniele Varrazzo [Thu, 30 Nov 2023 09:11:46 +0000 (10:11 +0100)]
refactor: use `yield from` in connections attempts
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
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.
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
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.
Daniele Varrazzo [Fri, 17 Nov 2023 16:00:08 +0000 (17:00 +0100)]
chore(ci): use existing macos11 packages in macOS arm build
Daniele Varrazzo [Fri, 17 Nov 2023 15:36:57 +0000 (16:36 +0100)]
chore: bump psycopg package version to 3.1.13
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.
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
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.
Daniele Varrazzo [Mon, 13 Nov 2023 20:12:45 +0000 (20:12 +0000)]
fix: add support for the 'load_balance_hosts' connection parameter
Daniele Varrazzo [Mon, 13 Nov 2023 18:08:51 +0000 (18:08 +0000)]
test: test conninfo attempts functions and multiple host support in connection
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.
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.
Daniele Varrazzo [Wed, 25 Oct 2023 18:23:08 +0000 (20:23 +0200)]
refactor: move setting autocommit on connection out of _connect_gen
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).
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.
Daniele Varrazzo [Sat, 11 Nov 2023 19:09:00 +0000 (19:09 +0000)]
Merge branch 'test-pool-3.2-psycopg-3.1'
Daniele Varrazzo [Sat, 11 Nov 2023 16:50:42 +0000 (16:50 +0000)]
ci: test psycopg pool package with released a psycopg version
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.
Daniele Varrazzo [Sat, 11 Nov 2023 16:57:17 +0000 (16:57 +0000)]
chore: bump psycopg_pool package version to 3.3.0.dev1
Daniele Varrazzo [Sat, 11 Nov 2023 15:30:55 +0000 (15:30 +0000)]
chore: fix mypy >= 1.7 warning in tests
Daniele Varrazzo [Sat, 11 Nov 2023 14:59:49 +0000 (14:59 +0000)]
chore: bump psycopg_pool package version to 3.2.0
Daniele Varrazzo [Sat, 11 Nov 2023 14:59:09 +0000 (14:59 +0000)]
fix(bump_version): fix bumping minor version with dev releases
Daniele Varrazzo [Thu, 2 Nov 2023 09:25:18 +0000 (10:25 +0100)]
chore(macos): build images with more recent Python versions
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
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
Daniele Varrazzo [Tue, 24 Oct 2023 08:50:40 +0000 (10:50 +0200)]
test: add test to generate an EINTR in wait_c
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
```
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().
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.
Daniele Varrazzo [Sat, 14 Oct 2023 07:45:52 +0000 (09:45 +0200)]
Merge branch 'pool-getconn-safe'
Daniele Varrazzo [Sat, 7 Oct 2023 02:16:43 +0000 (04:16 +0200)]
docs(pool): document check callback, drop previous recipes and rants
Daniele Varrazzo [Fri, 6 Oct 2023 16:31:52 +0000 (18:31 +0200)]
test(pool): add tests to verify check on getconn's behaviour
Daniele Varrazzo [Fri, 6 Oct 2023 16:30:18 +0000 (18:30 +0200)]
fix(pool): clean up logging in getconn check
If a check callback is set, assume that failed checks on getconn are
just part of normal operative life: don't consider them warnings.
Daniele Varrazzo [Fri, 6 Oct 2023 13:15:04 +0000 (15:15 +0200)]
feat(pool): add `check` connection parameter
Allow to specify a callback to call on getconn and discard the
connection if not in working state.
Daniele Varrazzo [Fri, 6 Oct 2023 13:13:39 +0000 (15:13 +0200)]
feat(pool): add `check_connection()` method
The method is public, will be documented as available to use as check
parameter, but also used internally by the `check()` method.
Daniele Varrazzo [Fri, 6 Oct 2023 11:00:41 +0000 (13:00 +0200)]
refactor(pool): introduce a loop in getconn to allow connection check
Daniele Varrazzo [Sat, 14 Oct 2023 07:40:00 +0000 (09:40 +0200)]
Merge branch 'pool-warn-implicit-open'
Daniele Varrazzo [Fri, 13 Oct 2023 23:51:11 +0000 (01:51 +0200)]
docs(pool): warn about future behaviour changes of open on init
Daniele Varrazzo [Sun, 8 Oct 2023 18:43:47 +0000 (20:43 +0200)]
feat(pool): raise a warning if async pools are open in the constructor
Daniele Varrazzo [Sat, 7 Oct 2023 22:01:57 +0000 (00:01 +0200)]
feat(pool) raise a warning if the pool is expected to be opened implicitly
Daniele Varrazzo [Wed, 11 Oct 2023 23:06:47 +0000 (01:06 +0200)]
refactor: define conn_encoding on pgconn_encoding
Also more consistent use of the two functions throughout the codebase.
Daniele Varrazzo [Fri, 13 Oct 2023 23:52:05 +0000 (01:52 +0200)]
chore: move codespell configuration to toml file
Configuration tweaked to avoid files commonly found in dev environments.
Daniele Varrazzo [Sun, 8 Oct 2023 17:31:07 +0000 (19:31 +0200)]
style(pool): more explicit error message for pool open with no loop
Daniele Varrazzo [Fri, 13 Oct 2023 22:52:36 +0000 (00:52 +0200)]
Merge branch 'async-to-sync'
Daniele Varrazzo [Fri, 13 Oct 2023 22:49:51 +0000 (23:49 +0100)]
Merge pull request #660 from dlax/async-to-sync
improvements to tools/async_to_sync.py
Denis Laxalde [Fri, 13 Oct 2023 07:40:09 +0000 (09:40 +0200)]
refactor: allow to use podman container engine in async_to_sync.py
Daniele Varrazzo [Fri, 13 Oct 2023 14:04:12 +0000 (16:04 +0200)]
feat(tools): warn about the Python version used in async-to-sync
Notify the user that they may get spurious results.
Denis Laxalde [Fri, 13 Oct 2023 07:36:28 +0000 (09:36 +0200)]
fix(tools): remove mention of dropped shell script in async_to_sync.py
Denis Laxalde [Fri, 13 Oct 2023 06:51:54 +0000 (08:51 +0200)]
refactor: use text mode for subprocess in async_to_sync.py
Denis Laxalde [Fri, 13 Oct 2023 06:54:01 +0000 (08:54 +0200)]
refactor: replace 'git ls-files' + 'grep' by a single 'git grep'
Daniele Varrazzo [Fri, 13 Oct 2023 01:35:26 +0000 (03:35 +0200)]
chore: use Python 3.11 to conver async to sync
Daniele Varrazzo [Fri, 13 Oct 2023 01:22:04 +0000 (03:22 +0200)]
chore: add option to run async_to_sync in a docker image
This allows to specify which Python version to use for the conversion
(even when it's not installed on the machine).
Daniele Varrazzo [Fri, 13 Oct 2023 00:19:03 +0000 (02:19 +0200)]
refactor: drop 'convert_async_to_sync.sh' script
Do all in 'async_to_sync.py:' added --all and --check options.
Daniele Varrazzo [Wed, 11 Oct 2023 11:30:46 +0000 (13:30 +0200)]
test: drop unneeded raise on pytest.skip()
Daniele Varrazzo [Sun, 8 Oct 2023 13:55:31 +0000 (15:55 +0200)]
refactor(test): uniform the way sync/async-only tests are skipped
Add @skip_sync, @skip_async markers to mark the functions to skip.
Daniele Varrazzo [Sun, 8 Oct 2023 10:33:47 +0000 (12:33 +0200)]
test: add check to verify the completeness of convert_async_to_sync
Verify that all the files commented as having been automatically
converted are actually included in the script converting them.
Daniele Varrazzo [Sun, 8 Oct 2023 09:55:58 +0000 (11:55 +0200)]
style: more care in the docstring mentioning sync/async versions of the code
Daniele Varrazzo [Sun, 8 Oct 2023 09:45:28 +0000 (11:45 +0200)]
refactor(pool): define scheduler task as dataclass
Daniele Varrazzo [Sun, 8 Oct 2023 09:02:23 +0000 (11:02 +0200)]
refactor(async_to_sync): create new object without listing all the attributes
Daniele Varrazzo [Sun, 8 Oct 2023 08:32:29 +0000 (10:32 +0200)]
style(pool): use `pass` instead of `return` for empty methods
Daniele Varrazzo [Sun, 8 Oct 2023 08:30:26 +0000 (09:30 +0100)]
docs: fix typos/grammar
Co-authored-by: Daniel Fortunov <asqui@users.noreply.github.com>
Daniele Varrazzo [Fri, 6 Oct 2023 10:58:49 +0000 (12:58 +0200)]
refactor(copy): generate sync code from async
Daniele Varrazzo [Thu, 5 Oct 2023 23:58:54 +0000 (01:58 +0200)]
refactor(test): add acompat module
Daniele Varrazzo [Fri, 6 Oct 2023 13:02:50 +0000 (15:02 +0200)]
feat(tools): allow to specify the files to convert async to sync
Daniele Varrazzo [Thu, 5 Oct 2023 03:10:00 +0000 (05:10 +0200)]
fix: fix type annotation problems on Python 3.8, 3.9
Daniele Varrazzo [Thu, 5 Oct 2023 02:06:34 +0000 (04:06 +0200)]
refactor(pool): generate null pool module from async counterpart
Daniele Varrazzo [Thu, 5 Oct 2023 01:58:57 +0000 (03:58 +0200)]
refactor(pool): move null pool base to its own module
And some more light refactoring.
Daniele Varrazzo [Thu, 5 Oct 2023 01:40:28 +0000 (03:40 +0200)]
refactor(pool): generate pool sync module from async counterpart
Daniele Varrazzo [Thu, 5 Oct 2023 00:57:08 +0000 (02:57 +0200)]
refactor(pool): add Worker/AWorker type aliases
With these we don't have direct dependencies on the asyncio and
threading modules in the pool classes.
Daniele Varrazzo [Thu, 5 Oct 2023 00:43:50 +0000 (02:43 +0200)]
refactor(pool): give sync attribute the same life cycle of the async one
Create possibly async objects only after we are sure that a loop is
running.
Daniele Varrazzo [Thu, 5 Oct 2023 00:22:20 +0000 (02:22 +0200)]
refactor(pool): use non-string typing annotations
Daniele Varrazzo [Thu, 5 Oct 2023 00:21:15 +0000 (02:21 +0200)]
refactor(pool): add functions to get current thread/task name
The latter is only possible as we dropped support for Python 3.7.
Daniele Varrazzo [Wed, 4 Oct 2023 22:21:58 +0000 (00:21 +0200)]
refactor(pool): add Queue/AQueue compatibility objects
Daniele Varrazzo [Wed, 4 Oct 2023 22:01:24 +0000 (00:01 +0200)]
refactor(pool): add spawn/gather async compat functions
Daniele Varrazzo [Wed, 4 Oct 2023 20:44:48 +0000 (22:44 +0200)]
refactor(pool): add psycopg_pool._acompat to ease async/sync differences
Daniele Varrazzo [Wed, 4 Oct 2023 20:02:58 +0000 (22:02 +0200)]
refactor(pool): add psycopg_pool.abc module
Daniele Varrazzo [Wed, 4 Oct 2023 18:38:44 +0000 (20:38 +0200)]
chore: make ast-comments an ordinary dev dependency
Daniele Varrazzo [Mon, 2 Oct 2023 10:08:09 +0000 (12:08 +0200)]
ci: pin ast-comments to work around bug, document other bug as submitted
Daniele Varrazzo [Sun, 1 Oct 2023 01:59:37 +0000 (03:59 +0200)]
refactor(pool): light refactor to align async and sync pool
Daniele Varrazzo [Tue, 12 Sep 2023 05:08:21 +0000 (07:08 +0200)]
refactor(tests): generate null pool tests from async counterpart
Daniele Varrazzo [Tue, 12 Sep 2023 04:48:10 +0000 (06:48 +0200)]
refactor(tests): generate most pool tests using parametric fixture
Daniele Varrazzo [Mon, 11 Sep 2023 22:19:22 +0000 (23:19 +0100)]
refactor(tests): rename cursor tests to keep them together
Also rename test_default_cursor to just test_cursor as we renamed the
common tests in the previous commit.
Daniele Varrazzo [Mon, 11 Sep 2023 22:15:11 +0000 (23:15 +0100)]
refactor(tests): rename test_cursor to test_cursor_common
Daniele Varrazzo [Mon, 11 Sep 2023 21:57:44 +0000 (22:57 +0100)]
refactor(tests): generate test_pool from async counterpart
Daniele Varrazzo [Mon, 11 Sep 2023 17:50:44 +0000 (18:50 +0100)]
refactor(tests): generate test_sched from async counterpart
Daniele Varrazzo [Mon, 11 Sep 2023 16:10:17 +0000 (17:10 +0100)]
refactor(pool): generate Scheduler from AsyncScheduler
Daniele Varrazzo [Sat, 2 Sep 2023 21:22:09 +0000 (22:22 +0100)]
refactor: generate connection.py from connection_async
Daniele Varrazzo [Sat, 2 Sep 2023 21:18:30 +0000 (22:18 +0100)]
refactor(async_to_sync): finally solved the Tuple mystery
The problem came from names shadowing in the ast_comment module. To be
reported upstream.
Daniele Varrazzo [Sat, 2 Sep 2023 21:10:05 +0000 (22:10 +0100)]
refactor(connection): harmless manipulation to minimize async conversion diff
Daniele Varrazzo [Sat, 2 Sep 2023 21:05:28 +0000 (22:05 +0100)]
docs: copy connection docstrings to async class
Daniele Varrazzo [Sat, 2 Sep 2023 20:47:20 +0000 (21:47 +0100)]
perf(waiting): drop unneeded wait_for in wait_conn_async if no timeout is set
Daniele Varrazzo [Sat, 2 Sep 2023 20:41:32 +0000 (21:41 +0100)]
feat(connection): add set_autocommit() and similar methods