Make the repositoryactioncount worker disconnect from the DB between runs
This commit is contained in:
parent
75e32ad700
commit
6eaf1dbb3f
1 changed files with 30 additions and 28 deletions
|
@ -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()
|
||||
|
|
Reference in a new issue