APS-USAXS / livedata

live data from the APS USAXS instrument
https://usaxslive.xray.aps.anl.gov/
0 stars 0 forks source link

XMLSyntaxError from recent_spec_data_files.py #31

Closed prjemian closed 5 years ago

prjemian commented 5 years ago

An error email was sent from cron today:

Subject: Cron usaxs@usaxscontrol /home/beams/USAXS/Documents/eclipse/USAXS/livedata/buildSpecPlots.sh 2>&1 > /dev/null

Traceback (most recent call last):
 File "./recent_spec_data_files.py", line 65, in <module>
   main()
 File "./recent_spec_data_files.py", line 61, in main
   print("\n".join(list_recent_spec_data_files()))
 File "./recent_spec_data_files.py", line 40, in list_recent_spec_data_files
   xml_doc = lxml_etree.parse(SCANLOG_XML_FILE)
 File "src/lxml/etree.pyx", line 3435, in lxml.etree.parse
 File "src/lxml/parser.pxi", line 1840, in lxml.etree._parseDocument
 File "src/lxml/parser.pxi", line 1866, in lxml.etree._parseDocumentFromURL
 File "src/lxml/parser.pxi", line 1770, in lxml.etree._parseDocFromFile
 File "src/lxml/parser.pxi", line 1163, in lxml.etree._BaseParser._parseDocFromFile
 File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
 File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
 File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
 File "/share1/local_livedata/scanlog.xml", line 24610
lxml.etree.XMLSyntaxError: Couldn't find end of Start Tag en line 24610, line 24610, column 6
prjemian commented 5 years ago

@jilavsky: Aha. That's trying to read an XML file that is incomplete, probably in the state of being written when the read was attempted. Need to trap that, perhaps with a retry maximum.

prjemian commented 5 years ago

Seems like an intermittent problem. Surprised it appeared so quickly (within a week of the new code installed). This should help by retrying, with a 5s delay between retries, allowing for the XML file write to complete. With max of 5 retries, a delay of up to 20s seems reasonable. We can adjust if necessary.