xml schema validation runs very slow on aws lambda python runtime
Bug #1929126 reported by
richard wu
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I have a test code where it loads a set xsd files and validates against a xml string, when it runs on my linux box using python3.8, it finishes in milliseconds, but when it runs aws lambda python3.8 runtime, it finishes in 15 seconds. any thoughts what could be the reason.
To post a comment you must log in.
import time /www.liquid- technologies. com) --> <ns2:SignalProc essingNotificat ion acquisitionPoin tIdentity= "C1P4HV11- 1999983. dfw.720" xmlns=" urn:cablelabs: md:xsd: signaling: 3.0" xmlns:ns6= "urn:cablelabs: iptvservices: esam:xsd: manifest: 1" xmlns:ns5= "urn:cablelabs: iptvservices: esam:xsd: common: 1" xmlns:ns2= "urn:cablelabs: iptvservices: esam:xsd: signal: 1" xmlns:ns4= "urn:cablelabs: md:xsd: content: 3.0" xmlns:ns3= "urn:cablelabs: md:xsd: core:3. 0"> <ns5:Ext eventName= "esamEndpoint" /> <ns2:ResponseSignal action="replace" acquisitionPoin tIdentity= "C1P4HV11- 1999983. dfw.720" acquisitionSign alID="424c514b- e4ce-4003- 801e-719761563c d7"> <UTCPoint utcPoint= "2021-04- 30T18:40: 52.821Z" /> <BinaryData signalType= "SCTE35" >/DBQAAAAAAAA/ //wFAUAAAfRf+ /+T/iBBX4AUmXAA AEBAQArAQpDVUVJ PJ8jKjAwAh1DVUV JAAAH0X/ /AABScXoBCTExMz YzNTIyMTYAAB+ wVcY=</ BinaryData> </ns2:ResponseS ignal> </ns2:SignalPro cessingNotifica tion>'
from lxml import etree
xml_in = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!-- Created with Liquid Studio 2021 (https:/
#xml_in = '<?xml version="1.0" encoding="utf-8"?> <!-- Created with Liquid Studio 2021 (https:/ /www.liquid- technologies. com) --> <ns4:SignalProc essingEvent xmlns:ns2= "urn:cablelabs: iptvservices: esam:xsd: common: 1" xmlns=" urn:cablelabs: md:xsd: core:3. 0" xmlns:ns4= "urn:cablelabs: iptvservices: esam:xsd: signal: 1" xmlns:ns3= "urn:cablelabs: md:xsd: signaling: 3.0" xmlns:ns5= "urn:cablelabs: iptvservices: esam:xsd: manifest: 1" xmlns:ns6= "urn:cablelabs: md:xsd: content: 3.0"> <ns2:BatchInfo batchId= "B56CEA1A- 3F5F-48CD- B411-8BC3609E5F 16"> <ns2:Source uriId=" mag2-mx5- suits"> <ns6:SourceUrl> mag2-mx5- suits</ ns6:SourceUrl> </ns2:Source> </ns2:BatchInfo> <ns4:ResponseSignal action="create" acquisitionPoin tIdentity= "mag2-mx5- suits:SCTE35: 66" signalPointID= "MUQyNTkzQzgtMz M3Ri00NQ= =" acquisitionSign alID="424c514b- e4ce-4003- 801e-719761563c d7"> <ns3:NPTPoint nptPoint= "14866917. 257" /> <ns3:BinaryData signalType= "SCTE35" >/DAlAH+ DGqLsAP/ //wUAH2gIAOCABU FDVYAAUmXAAAAAA AAAV7AxRg= =</ns3: BinaryData> </ns4:ResponseS ignal> </ns4:SignalPro cessingEvent> '
xml_in = xml_in. encode( 'ascii' )
def validate(xml_path: str, xsd_path: str) -> bool:
xmlschema_doc = etree.parse( xsd_path) (xmlschema_ doc)
xmlschema = etree.XMLSchema
result = False
try:
xml_doc = etree.XML(xml_in)
except Exception as inst:
print(inst)
return result
try:
xmlschema. assertValid( xml_doc)
print('XML valid, schema validation ok.')
result = True
except etree.DocumentI nvalid as err:
print( "ERROR: " + str(type(err)))
print( "ERROR: " + str(err))
print( "ERROR: " + str(dir(err)))
print( "ERROR: " + str(err.error_log))
print( "dddddddddddddd dddddddddddd" ) error_log:
print( str(dir( error)) )
print( error.path)
print( error.message)
print( str(ex) )
for error in xmlschema.
except Exception as ex:
##result = xmlschema. validate( xml_doc)
return result
tic = time.perf_counter() OC-SP-ESAM- API-I03- Signal. xsd"): "./test. xml", "./OC-SP- ESAM-API- C01-Signal. xsd"): "./test. xml...
if validate(xml_in, "./schema/
#if validate(
#if validate(xml_in, "./SCTE35.xsd"):
#if validate(