Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Catch sqlite3.ProgrammingError along peewees OperationalError
Browse files Browse the repository at this point in the history
  • Loading branch information
jiivan committed Jul 15, 2019
1 parent f45c31a commit f5929df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions golem/database/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
import logging
import os
import sqlite3
import time
from typing import Optional, Type, Sequence

Expand All @@ -27,11 +28,14 @@ def execute_sql(self, sql, params=None, require_commit=True):
iterations += 1
try:
return super().execute_sql(sql, params, require_commit)
except peewee.OperationalError as e:
except (
sqlite3.ProgrammingError,
peewee.OperationalError,
) as e:
# Ignore transaction rollbacks
if str(e).startswith('no such savepoint'):
logger.warning('execute_sql() tx rollback failed: %r', e)
return
return None
# Check retry deadline
elif datetime.datetime.now() > deadline:
logger.warning(
Expand Down
6 changes: 3 additions & 3 deletions golem/network/transport/msg_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def get(node_id: str) -> typing.Iterator['message.base.Base']:
with READ_LOCK:
try:
db_model = model.QueuedMessage.select()\
.where(
model.QueuedMessage.node == node_id,
).order_by(model.QueuedMessage.created_date).get()
.where(
model.QueuedMessage.node == node_id,
).order_by(model.QueuedMessage.created_date).get()
except model.QueuedMessage.DoesNotExist:
return
try:
Expand Down
1 change: 1 addition & 0 deletions golem/task/server/queue_.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

logger = logging.getLogger(__name__)


class TaskMessagesQueueMixin:
"""Message Queue functionality for TaskServer"""

Expand Down

0 comments on commit f5929df

Please sign in to comment.