Log slow json saves

main
Bob Mottram 2019-11-15 23:03:37 +00:00
parent 0990bab4d1
commit ef9056761b
1 changed files with 11 additions and 0 deletions

View File

@ -774,6 +774,7 @@ class PubServer(BaseHTTPRequestHandler):
#pprint(messageJson)
beginSaveTime=time.time()
# save the json for later queue processing
queueFilename = \
savePostToInboxQueue(self.server.baseDir,
@ -789,6 +790,16 @@ class PubServer(BaseHTTPRequestHandler):
# add json to the queue
if queueFilename not in self.server.inboxQueue:
self.server.inboxQueue.append(queueFilename)
if self.server.debug:
timeDiff=int((time.time()-beginSaveTime)*1000)
if timeDiff>200:
print('WARN: slow save of inbox queue item '+queueFilename+' took '+str(timeDiff)+' mS')
try:
with open(queueFilename, 'r') as fp:
queueJson=commentjson.load(fp)
print('SLOW: '+str(queueJson))
except:
pass
self.send_response(201)
self.end_headers()
self.server.POSTbusy=False