(self, node, consumer, pause_flag)
Set node pause flag and wait for confirmation.
Set node pause flag and wait for confirmation.
Set node pause flag and wait for confirmation .
def set_paused(self, node, consumer, pause_flag):
        """Set node pause flag and wait for confirmation."""

        q = "select * from pgq_node.set_consumer_paused(%s, %s, %s)"
        self.node_cmd(node, q, [self.queue_name, consumer, pause_flag])

        self.log.info('Waiting for worker to accept')
        while 1:
            q = "select * from pgq_node.get_consumer_state(%s, %s)"
            stat = self.node_cmd(node, q, [self.queue_name, consumer], quiet = 1)[0]
            if stat['paused'] != pause_flag:
                raise Exception('operation canceled? %s <> %s' % (repr(stat['paused']), repr(pause_flag)))

            if stat['uptodate']:
                op = pause_flag and "paused" or "resumed"
                self.log.info("Consumer '%s' on node '%s' %s", consumer, node, op)
                return
            time.sleep(1)
        raise Exception('process canceled')
def set_paused ( self , node , consumer , pause_flag ) : q = "select * from pgq_node.set_consumer_paused(%s, %s, %s)" self . node_cmd ( node , q , [ self . queue_name , consumer , pause_flag ] ) self . log . info ( 'Waiting for worker to accept' ) while 1 : q = "select * from pgq_node.get_consumer_state(%s, %s)" stat = self . node_cmd ( node , q , [ self . queue_name , consumer ] , quiet = 1 ) [ 0 ] if stat [ 'paused' ] != pause_flag : raise Exception ( 'operation canceled? %s <> %s' % ( repr ( stat [ 'paused' ] ) , repr ( pause_flag ) ) ) if stat [ 'uptodate' ] : op = pause_flag and "paused" or "resumed" self . log . info ( "Consumer '%s' on node '%s' %s" , consumer , node , op ) return time . sleep ( 1 ) raise Exception ( 'process canceled' )