diff --git a/rattail/db/sync/__init__.py b/rattail/db/sync/__init__.py index 3432785c384eca34ea1b09ad3b22458a3839715a..b59117ec760b86af591130b1eecf374e87852b2c 100644 --- a/rattail/db/sync/__init__.py +++ b/rattail/db/sync/__init__.py @@ -103,7 +103,7 @@ class Synchronizer(object): ', '.join(self.remote_engines.iterkeys()))) while True: try: - self.synchronize_changes() + self.synchronize() except OperationalError, error: if error.connection_invalidated: # Presumably a database server restart; give it a moment @@ -303,8 +303,10 @@ def synchronize_changes(local_engine, remote_engines): factory = edbob.config.get('rattail.db', 'sync.synchronizer_class') if factory: + log.debug("synchronize_changes: using custom synchronizer factory: {0}".format(repr(factory))) factory = edbob.load_spec(factory) else: + log.debug("synchronize_changes: using default synchronizer factory") factory = Synchronizer synchronizer = factory(local_engine, remote_engines) diff --git a/rattail/db/sync/win32.py b/rattail/db/sync/win32.py index 058a3469ccea302439abcafcbaa92b16943162b0..3b467f8a7988dc964d7ec010b7dbbb1eccec65a4 100644 --- a/rattail/db/sync/win32.py +++ b/rattail/db/sync/win32.py @@ -31,8 +31,9 @@ import logging import threading import edbob -from edbob.win32 import Service +from edbob import db +from rattail.win32.service import Service from rattail.db.sync import get_sync_engines, synchronize_changes @@ -62,15 +63,14 @@ class DatabaseSynchronizerService(Service): edbob.init_modules(['rattail.db']) - engines = get_sync_engines() - if not engines: + remote_engines = get_sync_engines() + if not remote_engines: return False thread = threading.Thread(target=synchronize_changes, - args=(engines,)) + args=(db.engine, remote_engines)) thread.daemon = True thread.start() - return True diff --git a/tests/db/sync/test_init.py b/tests/db/sync/test_init.py index d23ab9e3c97b19bb70bb9b67aa2b4e648c1a4501..14066530346ea88dc147d2903b77c97e27d23490 100644 --- a/tests/db/sync/test_init.py +++ b/tests/db/sync/test_init.py @@ -36,12 +36,12 @@ class SynchronizerTests(TestCase): synchronizer = sync.Synchronizer(self.local_engine, self.remote_engines) with patch.object(synchronizer, 'sleep') as sleep: - with patch.object(synchronizer, 'synchronize_changes') as synchronize_changes: + with patch.object(synchronizer, 'synchronize') as synchronize: - synchronize_changes.side_effect = [1, 2, 3, FakeOperationalError(True), + synchronize.side_effect = [1, 2, 3, FakeOperationalError(True), 5, 6, 7, FakeOperationalError(False)] self.assertRaises(FakeOperationalError, synchronizer.loop) - self.assertEqual(synchronize_changes.call_count, 8) + self.assertEqual(synchronize.call_count, 8) self.assertEqual(sleep.call_args_list, [ call(3), call(3), call(3), call(5), call(3), call(3), call(3), call(3)])