Configure shop app, admin sidebar, media routing, and Stripe dependencies
This commit is contained in:
commit
93d83a0d63
188 files changed
+9220
No files matched your search
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,30 @@
|
||||
import logging
|
||||
from time import sleep
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import DatabaseError, close_old_connections
|
||||
|
||||
from catalog.newsletter import process_one
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Process the Studio newsletter outbox.'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('--once', action='store_true', help='Process up to one item and exit.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
while True:
|
||||
close_old_connections()
|
||||
try:
|
||||
worked = process_one()
|
||||
except DatabaseError:
|
||||
if options['once']:
|
||||
raise
|
||||
logger.warning('Newsletter worker: database unavailable; waiting.')
|
||||
worked = False
|
||||
if options['once']:
|
||||
return
|
||||
sleep(2 if worked else 5)
|
||||
Reference in new issue
Block a user