Close the db connections on the workers occasionally.
This commit is contained in:
parent
081041b85f
commit
f8f4c55f89
2 changed files with 15 additions and 0 deletions
|
@ -7,6 +7,7 @@ import argparse
|
|||
from apscheduler.scheduler import Scheduler
|
||||
|
||||
from data.queue import image_diff_queue
|
||||
from data.database import db as db_connection
|
||||
from endpoints.registry import process_image_changes
|
||||
|
||||
|
||||
|
@ -37,6 +38,10 @@ def process_work_items():
|
|||
|
||||
logger.debug('No more work.')
|
||||
|
||||
if not db_connection.is_closed():
|
||||
logger.debug('Closing thread db connection.')
|
||||
db_connection.close()
|
||||
|
||||
|
||||
def start_worker():
|
||||
logger.debug("Scheduling worker.")
|
||||
|
|
|
@ -15,6 +15,7 @@ from requests.exceptions import ConnectionError
|
|||
from data.queue import dockerfile_build_queue
|
||||
from data.userfiles import UserRequestFiles
|
||||
from data import model
|
||||
from data.database import db as db_connection
|
||||
from app import app
|
||||
|
||||
|
||||
|
@ -201,6 +202,11 @@ def babysit_builder(request):
|
|||
logger.exception('Exception processing job: %s' % outer_ex.message)
|
||||
return False
|
||||
|
||||
finally:
|
||||
if not db_connection.is_closed():
|
||||
logger.debug('Closing thread db connection.')
|
||||
db_connection.close()
|
||||
|
||||
|
||||
def process_work_items(pool):
|
||||
logger.debug('Getting work item from queue.')
|
||||
|
@ -231,6 +237,10 @@ def process_work_items(pool):
|
|||
|
||||
logger.debug('No more work.')
|
||||
|
||||
if not db_connection.is_closed():
|
||||
logger.debug('Closing thread db connection.')
|
||||
db_connection.close()
|
||||
|
||||
|
||||
def start_worker():
|
||||
pool = ThreadPool(3)
|
||||
|
|
Reference in a new issue