def process_fp(fp, p, sparse):
if _PROFILE:
pr = cProfile.Profile()
pr.enable()
beg = time.time()
try:
p.ParseFile(fp)
except xml.parsers.expat.ExpatError as err:
app.logger.error("Bad XML: %r" % err)
sparse.exceptions += 1
# Bulk upload the remainder
sparse._bulk_upload()
end = time.time()
if _PROFILE:
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
app.logger.info(s.getvalue())
return beg, end
评论列表
文章目录