Skip to content

Commit

Permalink
https://github.com/openzim/sotoki/issues/243
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCrazyT committed Jun 30, 2022
1 parent 8847cba commit 14fdb1c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/sotoki/utils/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ def run(self):
# parse XML file. not using defusedxml for performances reasons.
# although containing user-generated content, we trust Stack Exchange dump
parser = xml.sax.make_parser() # nosec
parser.setContentHandler(self.walker(processor=self.processor_callback))
parser.parse(self.fpath)
parser.setContentHandler(None)
try:
parser.setContentHandler(self.walker(processor=self.processor_callback))
parser.parse(self.fpath)
parser.setContentHandler(None)
finally:
try:
parser.close()
except xml.sax.SAXException as e:
logger.debug(str(e))
logger.debug(f"Done parsing {type(self).__name__}, collecting workers…")

# await offloaded processing
Expand Down

0 comments on commit 14fdb1c

Please sign in to comment.