Close #173.
Current release
---------------
+Psycopg 3.0.6
+^^^^^^^^^^^^^
+
+- `ServerCursor.close()` doesn't raise exceptions if the connection is closed
+ (:ticket:`#173`).
+
+
Psycopg 3.0.5
^^^^^^^^^^^^^
with self._conn.lock:
if self.closed:
return
- self._conn.wait(self._helper._close_gen(self))
+ if not self._conn.closed:
+ self._conn.wait(self._helper._close_gen(self))
super().close()
def execute(
async with self._conn.lock:
if self.closed:
return
- await self._conn.wait(self._helper._close_gen(self))
+ if not self._conn.closed:
+ await self._conn.wait(self._helper._close_gen(self))
await super().close()
async def execute(
cur.close()
+def test_close_broken_conn(conn):
+ cur = conn.cursor("foo")
+ conn.close()
+ cur.close()
+ assert cur.closed
+
+
def test_cursor_close_fetchone(conn):
cur = conn.cursor("foo")
assert not cur.closed
await cur.close()
+async def test_close_broken_conn(aconn):
+ cur = aconn.cursor("foo")
+ await aconn.close()
+ await cur.close()
+ assert cur.closed
+
+
async def test_cursor_close_fetchone(aconn):
cur = aconn.cursor("foo")
assert not cur.closed