def execute(token):
        message = token.message

        # create and send result message
        correlationid = message.correlationid
        receiveraddress = message.sender.hostname
        category = to_response_category(message.category)
        body = token.result
        resultmessage = messaging_uow.store_outgoing(receiveraddress, correlationid, category, body)

        process_outgoingmessage.delay(resultmessage.id)
Exemplo n.º 2
0
    def get(self, receiveraddress):
        query = self.get_parameter('query')

        if query is None:
            raise badrequest('parameter "query" not provided')

        # persist so it can be processed in the background
        correlationid = gen_correlationid()
        message = messaging_uow.store_outgoing(receiveraddress, correlationid, MessageCategory.SPARQL_QUERY, query)

        try:
            outgoing = process_outgoingmessage.delay(message.id)

            def check(): return outgoing.ready() and messaging_uow.is_answered(message)
            self.asyncwait(check, 1, 30, self.write_responsetomessage, message)

        except TimeoutError:
            raise timeout('the incoming "SparqlQuery" request has timed out')
        except Exception:
            raise servererror('the incoming "SparqlQuery" request failed')