Example #1
0
    def _iter(self, sparql_results_type, fields, bindings, boolean, triples):
        queue = Queue.Queue()
        graph = Graph()
        for prefix, namespace_uri in NS.iteritems():
            graph.namespace_manager.bind(prefix, namespace_uri)

        triples = list(triples)
        with statsd.timer('humfrey.streaming.rdflib-serializer.add-triples.' +
                          self.plugin_name):
            graph += triples
        serializer_thread = threading.Thread(target=self._serialize_to_queue,
                                             args=(graph, queue))

        with statsd.timer('humfrey.streaming.rdflib-serializer.serialize.' +
                          self.plugin_name):
            serializer_thread.start()
            while True:
                type, value = queue.get()
                if type == 'data':
                    yield value
                elif type == 'sentinel':
                    break
                elif type == 'exception':
                    raise value[0], value[1], value[2]
            serializer_thread.join()
Example #2
0
    def _iter(self, sparql_results_type, fields, bindings, boolean, triples):
        queue = Queue.Queue()
        graph = Graph()
        for prefix, namespace_uri in NS.iteritems():
            graph.namespace_manager.bind(prefix, namespace_uri)

        triples = list(triples)
        with statsd.timer('humfrey.streaming.rdflib-serializer.add-triples.' + self.plugin_name):
            graph += triples
        serializer_thread = threading.Thread(target=self._serialize_to_queue,
                                             args=(graph, queue))

        with statsd.timer('humfrey.streaming.rdflib-serializer.serialize.' + self.plugin_name):
            serializer_thread.start()
            while True:
                type, value = queue.get()
                if type == 'data':
                    yield value
                elif type == 'sentinel':
                    break
                elif type == 'exception':
                    raise value[0], value[1], value[2]
            serializer_thread.join()
Example #3
0
    def _get_triples(self):
        if getattr(self, '_get_triples_called', False):
            raise AssertionError("Can only call get_triples once")
        self._get_triples_called = True
        self.mode = 'parse'
        queue = Queue.Queue()
        parser_thread = threading.Thread(target=self._parse_to_queue,
                                         args=(self._stream, queue))

        with statsd.timer('humfrey.streaming.rdflib-parser.' + self.plugin_name):
            parser_thread.start()
            while True:
                type, value = queue.get()
                if type == 'triple':
                    yield value
                elif type == 'sentinel':
                    break
                elif type == 'exception':
                    raise value[0], value[1], value[2]
            parser_thread.join()
Example #4
0
    def _get_triples(self):
        if getattr(self, '_get_triples_called', False):
            raise AssertionError("Can only call get_triples once")
        self._get_triples_called = True
        self.mode = 'parse'
        queue = Queue.Queue()
        parser_thread = threading.Thread(target=self._parse_to_queue,
                                         args=(self._stream, queue))

        with statsd.timer('humfrey.streaming.rdflib-parser.' +
                          self.plugin_name):
            parser_thread.start()
            while True:
                type, value = queue.get()
                if type == 'triple':
                    yield value
                elif type == 'sentinel':
                    break
                elif type == 'exception':
                    raise value[0], value[1], value[2]
            parser_thread.join()