Commit 3704589f authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Send message when syncing fails

parent 7c570add
......@@ -16,7 +16,7 @@
import logging
logger = logging.getLogger(__name__)
from agkyra.syncer import common
from agkyra.syncer import common, messaging
class FileClient(object):
......@@ -41,7 +41,11 @@ class FileClient(object):
if callback is not None:
callback(synced_source_state, synced_target_state)
except common.SyncError as e:
logger.warning(e)
msg = messaging.SyncErrorMessage(
objname=target_state.objname,
serial=source_handle.source_state.serial,
exception=e, logger=logger)
self.settings.messager.put(msg)
if isinstance(e, common.HardSyncError):
if failure_callback is not None:
failure_callback(source_handle.source_state)
......
......@@ -71,6 +71,17 @@ class AckSyncMessage(Message):
(self.archive, self.objname, self.serial))
class SyncErrorMessage(Message):
def __init__(self, *args, **kwargs):
Message.__init__(self, *args, **kwargs)
self.objname = kwargs["objname"]
self.serial = kwargs["serial"]
self.exception = kwargs["exception"]
self.logger.warning(
"Sync failed; object: '%s' serial: %s error: %s"
% (self.objname, self.serial, self.exception))
class CollisionMessage(Message):
def __init__(self, *args, **kwargs):
Message.__init__(self, *args, **kwargs)
......
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