From 4b04cbce5f13e4483b3c6fc40a0cd73383919b62 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Tue, 3 Dec 2024 17:07:43 +0200 Subject: [PATCH] feat: use streaming encoding in json serializer --- ckanext/collection/utils/serialize/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ckanext/collection/utils/serialize/__init__.py b/ckanext/collection/utils/serialize/__init__.py index 964241c..6ef7336 100644 --- a/ckanext/collection/utils/serialize/__init__.py +++ b/ckanext/collection/utils/serialize/__init__.py @@ -298,7 +298,7 @@ class JsonSerializer(StreamingSerializer[str, types.TDataCollection]): def stream(self): visible = self.attached.columns.visible - yield self.encoder.encode( + chunks = self.encoder.iterencode( [ { k: v @@ -308,6 +308,7 @@ def stream(self): for row in self.attached.data ], ) + yield from chunks class ChartJsSerializer(StreamingSerializer[str, types.TDataCollection]):