Commit f77a685d authored by Julien Muchembled's avatar Julien Muchembled

logger: do not leave sqlite transaction open

This should fix the following failure:

Traceback (most recent call last):
  File "bin/neostorage", line 23, in <module>
    neo.scripts.neostorage.main()
  File "neoppod/neo/scripts/neostorage.py", line 80, in main
    app.run()
  File "neoppod/neo/storage/app.py", line 167, in run
    logging.exception('Pre-mortem data:')
  File "/usr/lib/python2.6/logging/__init__.py", line 1088, in exception
    self.error(*((msg,) + args), **{'exc_info': 1})
  File "/usr/lib/python2.6/logging/__init__.py", line 1082, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.6/logging/__init__.py", line 1173, in _log
    self.handle(record)
  File "/usr/lib/python2.6/logging/__init__.py", line 1183, in handle
    self.callHandlers(record)
  File "neoppod/neo/lib/logger.py", line 210, in callHandlers
    self._queue(record)
  File "neoppod/neo/lib/logger.py", line 200, in _queue
    self._release()
  File "neoppod/neo/lib/logger.py", line 79, in _release
    self._async.pop()(self)
  File "neoppod/neo/lib/logger.py", line 96, in flush
    self.db.execute("BEGIN")
sqlite3.OperationalError: cannot start a transaction within a transaction
parent 9e638d04
......@@ -93,9 +93,12 @@ class NEOLogger(Logger):
def flush(self):
if self.db is None:
return
try:
self.db.execute("BEGIN")
for r in self._record_queue:
self._emit(r)
finally:
# Always commit, to not lose any record that we could emit.
self.db.commit()
self._record_queue.clear()
self._record_size = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment