@classmethod
    def _listen_for_jobs(cls, queue_names, connection_name, timeout):
        conn = cls.listen(connection_name, queue_names)

        while True:
            for notify in conn.notifies:
                if not notify.channel in queue_names:
                    continue
                elif notify.payload == 'stop':
                    raise DequeueTimeout(0)
                conn.notifies.remove(notify)
                logger.debug('Got job notification %s on queue %s'% (
                    notify.payload, notify.channel))
                return notify.channel
            else:
                r, w, e = select.select([conn], [], [], timeout)
                if not (r or w or e):
                    raise DequeueTimeout(timeout)
                logger.debug('Got data on %s' % (str(r[0])))
                conn.poll()
Get notification from postgresql channels
dataset/ETHPy150Open bretth/django-pq/pq/queue.py/Queue._listen_for_jobs