Skip to content

Commit

Permalink
Communication: sax parser: add flush() after feed() (#556) (#569)
Browse files Browse the repository at this point in the history
This is due to libexpat 2.6 reparse deferral as documented in #556.

Unfortunately ExpatParser doesn't seem to have SetReparseDeferralEnabled(),
so we use an explicit flush() call to make sure all handlers are called
immediately. We control the source XML.

NOTE: Only available in Python 3.13 and backports.
  • Loading branch information
thiell authored Sep 11, 2024
1 parent e49f842 commit 5c6f17f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ClusterShell/Communication.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ def ev_read(self, worker, node, sname, msg):

try:
self._parser.feed(msg + b'\n')
if hasattr(self._parser, 'flush'): # GH#556
self._parser.flush()
except SAXParseException as ex:
self.logger.error("SAXParseException: %s: %s", ex.getMessage(), msg)
# Warning: do not send malformed raw message back
Expand Down

0 comments on commit 5c6f17f

Please sign in to comment.