Skip to content

Commit 738f7a8

Browse files
authored
Added logging around streaming docmaps index (#336)
1 parent c6cbaf7 commit 738f7a8

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

data_hub_api/docmaps/v2/provider.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,18 @@ def get_docmaps_by_manuscript_id(self, manuscript_id: str) -> Sequence[Docmap]:
7272
return list(self.iter_docmaps_by_manuscript_id(manuscript_id))
7373

7474
def iter_docmaps_index_json_stream(self):
75-
yield '{"docmaps":['
76-
first = True
77-
for docmap in self.iter_docmaps_by_manuscript_id():
78-
if not first:
79-
yield ','
80-
else:
81-
first = False
82-
yield json.dumps(docmap)
83-
yield ']}'
75+
LOGGER.info('Streaming docmaps index as JSON...')
76+
try:
77+
yield '{"docmaps":['
78+
first = True
79+
for docmap in self.iter_docmaps_by_manuscript_id():
80+
if not first:
81+
yield ','
82+
else:
83+
first = False
84+
yield json.dumps(docmap)
85+
yield ']}'
86+
except Exception as e:
87+
LOGGER.exception('Error while streaming docmaps index as JSON: %s', e)
88+
raise
89+
LOGGER.info('Finished streaming docmaps index as JSON.')

0 commit comments

Comments
 (0)