'Respond to the custom action event.
Since one of the actions is to disconnect, this
event handler needs to be run in threaded mode, by
using `threaded=True` in the `add_event_handler` call.'

def _handle_action_event(self, iq):

    method = iq['action']['method']
    param = iq['action']['param']
    if ((method == 'is_prime') and (param == '2')):
        print ('got    message:    %s' % iq)
        iq.reply()
        iq['action']['status'] = 'done'
        iq.send()
    elif (method == 'bye'):
        print ('got    message:    %s' % iq)
        self.disconnect()
    else:
        print ('got    message:    %s' % iq)
        iq.reply()
        iq['action']['status'] = 'error'
        iq.send()
