Skip to content

Commit

Permalink
Adds notifies processing in pq_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Konoval authored and dvarrazzo committed Oct 10, 2024
1 parent eaeeb76 commit 362cb00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions psycopg/pqpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ pq_commit(connectionObject *conn)
}

Py_BLOCK_THREADS;
conn_notifies_process(conn);
conn_notice_process(conn);
Py_UNBLOCK_THREADS;

Expand Down
12 changes: 12 additions & 0 deletions tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ def test_notifies_received_on_execute(self):
self.assertEqual(pid, self.conn.notifies[0][0])
self.assertEqual('foo', self.conn.notifies[0][1])

@slow
def test_notifies_received_on_commit(self):
self.listen("foo")
self.conn.commit()
self.conn.cursor().execute("select 1;")
pid = int(self.notify("foo").communicate()[0])
self.assertEqual(0, len(self.conn.notifies))
self.conn.commit()
self.assertEqual(1, len(self.conn.notifies))
self.assertEqual(pid, self.conn.notifies[0][0])
self.assertEqual("foo", self.conn.notifies[0][1])

@slow
def test_notify_object(self):
self.autocommit(self.conn)
Expand Down

0 comments on commit 362cb00

Please sign in to comment.