-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running send_queued_mail every 60s on Heroku - opens a new db connection every time - maxing out my connections #45
Comments
You should cron
|
Normally I would, but Heroku doesn't support cron jobs. |
This may not be the most up to date of instructions, but you can try something like this: http://guidovanoorschot.nl/adding-cron-jobs-to-a-django-project-with-heroku-scheduler/ Sent from my phone
|
Thanks. Scheduler works - but the max frequency is once every 5 mins. I My pseudo cron job on Heroku using apscheduler works, but it seems to open On Thu, Jan 30, 2014 at 6:22 AM, Selwin Ong notifications@github.comwrote:
|
SOLVED. I read somewhere that Django doesn't close db connections after running management commands. I tweaked my pseudo cron job as follows to explicitly close the db connection after send_queued_mail runs.
|
Does send_queued_mail close it's db connection when done? Doesn't seem to be. Perhaps it is how I am calling it via a scheduler so it runs every 60s. That file below as an fyi
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'anonqaproject.settings'
import logging
logging.basicConfig()
from apscheduler.scheduler import Scheduler
from post_office import utils
sched = Scheduler()
@sched.interval_schedule(minutes=1)
def timed_job():
utils.send_queued_mail()
sched.start()
while True:
pass
The text was updated successfully, but these errors were encountered: