diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-01-03 13:41:36 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-01-03 21:34:49 +0100 |
commit | 5f6e77357567bfba2046bd9fd4b8a2d3ad009d87 (patch) | |
tree | ed56fa0ea78c4a682acb2874492687cfe7220eb1 /tests/test_async.py | |
parent | 19ff51ae75914c2226888ac1a3ffecdc590d0ec7 (diff) | |
download | psycopg2-5f6e77357567bfba2046bd9fd4b8a2d3ad009d87.tar.gz |
Broken circular reference in async execution
If a connection is destroyed before an async operation is completed, the
`async_cursor` member creates a reference loop, leaving the connection and
the cursor alive. `async_cursor` is now a weak reference.
Diffstat (limited to 'tests/test_async.py')
-rwxr-xr-x | tests/test_async.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_async.py b/tests/test_async.py index 96d7a2c..d4854fc 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -415,6 +415,18 @@ class AsyncTests(unittest.TestCase): self.assertEqual("CREATE TABLE", cur.statusmessage) self.assert_(self.conn.notices) + def test_async_cursor_gone(self): + cur = self.conn.cursor() + cur.execute("select 42;"); + del cur + self.assertRaises(psycopg2.InterfaceError, self.wait, self.conn) + + # The connection is still usable + cur = self.conn.cursor() + cur.execute("select 42;"); + self.wait(self.conn) + self.assertEqual(cur.fetchone(), (42,)) + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__) |