Example #1
0
def test__processors__bulk_call():
    path = os.path.join(settings.DJANGO_ROOT, "void", "tests", "resources", "bulk_api_sample.txt")
    with open(path, 'r') as f:
        processor = BulkApiProcessor(f, store=rdfstore._rdfstore_test)
        assert processor
        processor.process()
        stats = processor._processing_statistics()
        assert stats
Example #2
0
def bulk_api(request):
    if request.method in ['PUT', 'POST']:
        content = request.data
        if not settings.BULK_API_ASYNC:
            processor = BulkApiProcessor(content)
            return Response(processor.process(), status=status.HTTP_201_CREATED)
        tasks.process_bulk_api_request.delay(content)
        return Response({'status': "ok"}, status=status.HTTP_201_CREATED)
Example #3
0
def process_bulk_api_request(self, request_payload):
    try:
        processor = BulkApiProcessor(request_payload)
        return processor.process()
    except URLError as ue:
        logger.error("Got url error for {}, but will retry again".format(ue))
        self.retry()
    except socket.timeout as to:
        logger.error("Got socket timeout for {}, but will retry again".format(to))
        self.retry()
    except socket.error as err:
        logger.error("Got socket error for {}, but will retry again".format(err))
        self.retry()