fix unprotected notify

This commit is contained in:
Sophia Yang 2026-05-15 11:01:59 -04:00
parent e315d821ae
commit 8ed0d3577d
2 changed files with 10 additions and 6 deletions

View File

@ -796,7 +796,7 @@ class Pool:
self.ncursors = 0
self.ntxns = 0
# This lock protects self.active_contexts, self.active_sockets,
# self.__pinned_sockets, self.ncursors, and self.ntxns.
# self.__pinned_sockets, self.ncursors, self.next_connection_id, and self.ntxns.
self._active_contexts_lock = _async_create_lock()
async def ready(self) -> None:
@ -867,8 +867,10 @@ class Pool:
async with self.lock:
self.state = PoolState.CLOSED
# Clear the wait queue
self._max_connecting_cond.notify_all()
self.size_cond.notify_all()
async with self._max_connecting_cond:
self._max_connecting_cond.notify_all()
async with self.size_cond:
self.size_cond.notify_all()
if interrupt_connections:
for context in self.active_contexts.copy():

View File

@ -794,7 +794,7 @@ class Pool:
self.ncursors = 0
self.ntxns = 0
# This lock protects self.active_contexts, self.active_sockets,
# self.__pinned_sockets, self.ncursors, and self.ntxns.
# self.__pinned_sockets, self.ncursors, self.next_connection_id, and self.ntxns.
self._active_contexts_lock = _create_lock()
def ready(self) -> None:
@ -865,8 +865,10 @@ class Pool:
with self.lock:
self.state = PoolState.CLOSED
# Clear the wait queue
self._max_connecting_cond.notify_all()
self.size_cond.notify_all()
with self._max_connecting_cond:
self._max_connecting_cond.notify_all()
with self.size_cond:
self.size_cond.notify_all()
if interrupt_connections:
for context in self.active_contexts.copy():