'Create and send two custom actions.
If the first action was successful, then send
a shutdown command and then disconnect.'

def send_custom_iq(self):

    iq = self.Iq()
    iq['to'] = self.action_provider
    iq['type'] = 'set'
    iq['action']['method'] = 'is_prime'
    iq['action']['param'] = '2'
    try:
        resp = iq.send()
        if (resp['action']['status'] == 'done'):
            iq2 = self.Iq()
            iq2['to'] = self.action_provider
            iq2['type'] = 'set'
            iq2['action']['method'] = 'bye'
            iq2.send(block=False)
            self.disconnect(wait=True)
    except XMPPError:
        print 'There    was    an    error    sending    the    custom    action.'
