Fix sanity check to use the relevant active connection

This commit is contained in:
Alan Rominger 2022-08-29 11:42:57 -04:00
parent 61f3e5cbed
commit 01037fa561
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559
2 changed files with 2 additions and 2 deletions

View File

@ -31,7 +31,7 @@ class PubSub(object):
cur.execute('SELECT pg_notify(%s, %s);', (channel, payload))
def events(self, select_timeout=5, yield_timeouts=False):
if not pg_connection.get_autocommit():
if not self.conn.autocommit:
raise RuntimeError('Listening for events can only be done in autocommit mode')
while True:

View File

@ -46,7 +46,7 @@ class Control(object):
reply_queue = Control.generate_reply_queue_name()
self.result = None
with pg_bus_conn() as conn:
with pg_bus_conn(new_connection=True) as conn:
conn.listen(reply_queue)
conn.notify(self.queuename, json.dumps({'control': command, 'reply_to': reply_queue}))