diff --git a/src/mailer/management/commands/runmailer.py b/src/mailer/management/commands/runmailer.py index 5e1b2fd..5fea8d8 100644 --- a/src/mailer/management/commands/runmailer.py +++ b/src/mailer/management/commands/runmailer.py @@ -1,6 +1,7 @@ import logging import sys from argparse import ArgumentParser +from contextlib import suppress from datetime import datetime from django.core.management import BaseCommand @@ -27,4 +28,5 @@ def handle(self, *args, **options): self.stdout.write("Starting django-mailer send loop.") quit_command = "CTRL-BREAK" if sys.platform == "win32" else "CONTROL-C" self.stdout.write(f"Quit the loop with {quit_command}.") - send_loop() + with suppress(KeyboardInterrupt): + send_loop() diff --git a/src/mailer/management/commands/runmailer_pg.py b/src/mailer/management/commands/runmailer_pg.py index 16a19d9..2cadfbd 100644 --- a/src/mailer/management/commands/runmailer_pg.py +++ b/src/mailer/management/commands/runmailer_pg.py @@ -1,6 +1,7 @@ import logging import sys from argparse import ArgumentParser +from contextlib import suppress from datetime import datetime from django.core.management import BaseCommand @@ -28,4 +29,5 @@ def handle(self, *args, **options): self.stdout.write("Starting django-mailer send loop.") quit_command = "CTRL-BREAK" if sys.platform == "win32" else "CONTROL-C" self.stdout.write(f"Quit the loop with {quit_command}.") - postgres_send_loop() + with suppress(KeyboardInterrupt): + postgres_send_loop()