Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openquake/baselib/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def count(word):
import socket
import signal
import pickle
import sqlite3
import getpass
import inspect
import logging
Expand Down Expand Up @@ -455,6 +456,9 @@ def new(cls, func, args, mon, sentbytes=0):
_etype, exc, tb = sys.exc_info()
res = Result(exc, mon, ''.join(traceback.format_tb(tb)))
else:
if isinstance(val, sqlite3.Cursor):
# happens when the DbServer performs an UPDATE command
val = val.lastrowid
res = Result(val, mon)
return res

Expand Down
9 changes: 7 additions & 2 deletions openquake/server/db/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,13 @@ def log(db, job_id, timestamp, level, process, message):
:param message:
message to store in the log record
"""
db('INSERT INTO log (job_id, timestamp, level, process, message) '
'VALUES (?X)', (job_id, timestamp, level, process, message))
try:
db('INSERT INTO log (job_id, timestamp, level, process, message) '
'VALUES (?X)', (job_id, timestamp, level, process, message))
except Exception as exc:
# not so serious to break the calculation
print(exc)



def get_log(db, job_id):
Expand Down
6 changes: 4 additions & 2 deletions openquake/server/dbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ def dworker(self, sock):
try:
func = getattr(actions, cmd)
except AttributeError: # SQL string
sock.send(p.safely_call(self.db, (cmd,) + args))
res = p.safely_call(self.db, (cmd,) + args)
sock.send(res)
else: # action
sock.send(p.safely_call(func, (self.db,) + args))
res = p.safely_call(func, (self.db,) + args)
sock.send(res)

def start(self):
"""
Expand Down