]> git.ipfire.org Git - thirdparty/psycopg.git/commit
fix(pool): make sure there are no connection in the pool after close()
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 10 Apr 2024 21:58:24 +0000 (23:58 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 12 Apr 2024 01:20:05 +0000 (03:20 +0200)
commit910383f0b23516f895f720a5e9f5a268b25fef89
treeaf3af42a6b38b5d38a2ebbafc56d80fdce7f0e93
parent5624303de16f6f634b72f5746f3aae9bef493ac7
fix(pool): make sure there are no connection in the pool after close()

The case has been reported in #784. While not easy to reproduce, it
seems that it might be caused by the pool being closed while a worker is
still trying to create a connection, which will be put in the _pool
state after supposedly no other operation should have been performed.

Stop the workers and then empty the pool only after they have stopped to
run.

Also refactor the cleanup of the pool and waiting queue, moving them
to close(). There is no reason why a method called "stop workers" should
empty them, and there is no other code path that use such feature.

Close #784.
docs/news_pool.rst
psycopg_pool/psycopg_pool/pool.py
psycopg_pool/psycopg_pool/pool_async.py