Skip to content
Snippets Groups Projects
Commit 114d5e3b authored by David Trattnig's avatar David Trattnig
Browse files

Autoflush Session.

parent 9ba83127
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,6 @@ from models import PlayLog, ActivityLog ...@@ -29,7 +29,6 @@ from models import PlayLog, ActivityLog
class SyncJob(threading.Thread): class SyncJob(threading.Thread):
""" """
Job periodically checking for data at one of the main nodes to be synchronized. Job periodically checking for data at one of the main nodes to be synchronized.
...@@ -44,7 +43,6 @@ class SyncJob(threading.Thread): ...@@ -44,7 +43,6 @@ class SyncJob(threading.Thread):
sync_interval = None sync_interval = None
sync_batch_size = None sync_batch_size = None
# Create a scoped local database session to be thread safe
Session = None Session = None
...@@ -62,19 +60,16 @@ class SyncJob(threading.Thread): ...@@ -62,19 +60,16 @@ class SyncJob(threading.Thread):
self.sync_batch_size = self.config.get("sync_batch_size") self.sync_batch_size = self.config.get("sync_batch_size")
self.logger.info("Initialized Sync Job - Synchronizing API Nodes every %s seconds and with a max batch-size of %s." % (self.sync_interval, self.sync_batch_size)) self.logger.info("Initialized Sync Job - Synchronizing API Nodes every %s seconds and with a max batch-size of %s." % (self.sync_interval, self.sync_batch_size))
# Create a scoped local database session to be thread safe
engine = create_engine(self.config.get_database_uri()) engine = create_engine(self.config.get_database_uri())
session_factory = sessionmaker(bind=engine) session_factory = sessionmaker(autoflush=True, autocommit=False, bind=engine)
self.Session = scoped_session(session_factory) self.Session = scoped_session(session_factory)
def run(self): def run(self):
""" """
Starts the Job. Starts the Job.
""" """
# with self.app.app_context():
self.synchronize() self.synchronize()
while not self.exit_event.wait(self.sync_interval): while not self.exit_event.wait(self.sync_interval):
self.synchronize() self.synchronize()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment