Merge pull request #12769 from AlanCoding/self_conn

Fix sanity check to use the relevant active connection
This commit is contained in:
Alan Rominger 2022-08-29 20:36:48 -04:00 committed by GitHub
commit 310e354164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)) cur.execute('SELECT pg_notify(%s, %s);', (channel, payload))
def events(self, select_timeout=5, yield_timeouts=False): 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') raise RuntimeError('Listening for events can only be done in autocommit mode')
while True: while True:

View File

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