Ejemplo n.º 1
0
def notify(cur, channel, payload=None):
  assert helpers.valid_channel(channel)
  s = 'NOTIFY {}{}{};'
  return cur.mogrify(s.format(
      str(channel),
      (', ' if payload is not None else ''),
      (repr(json.dumps(payload) if payload is not None else ''))
      ))
Ejemplo n.º 2
0
 def register_listen(self, channel, callback):
   assert helpers.valid_channel(channel)
   self._registrar[channel] = callback
   with self.conn.cursor() as cur:
     cur.execute("LISTEN {};".format(channel))