Make the repositoryactioncount worker disconnect from the DB between runs

This commit is contained in:
Joseph Schorr 2015-04-22 17:11:08 -04:00
parent 75e32ad700
commit 6eaf1dbb3f

View file

@ -3,7 +3,8 @@ import logging
from apscheduler.schedulers.blocking import BlockingScheduler
from app import app
from data.database import Repository, LogEntry, RepositoryActionCount, db_random_func, fn
from data.database import (Repository, LogEntry, RepositoryActionCount, db_random_func, fn,
UseThenDisconnect)
from datetime import date, datetime, timedelta
POLL_PERIOD_SECONDS = 30
@ -15,6 +16,7 @@ sched = BlockingScheduler()
def count_repository_actions():
""" Counts actions for a random repository for the previous day. """
with UseThenDisconnect(app.config):
try:
# Get a random repository to count.
today = date.today()