mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 16:23:44 -04:00
remove duplication shutdown loggers
also add **kwargs to make it celery4 compatible
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from celery import Celery, Task
|
from celery import Celery, Task
|
||||||
|
from celery.signals import worker_process_shutdown
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
|
|
||||||
|
@worker_process_shutdown.connect
|
||||||
|
def worker_process_shutdown(sender, signal, pid, exitcode, **kwargs):
|
||||||
|
current_app.logger.info('worker shutdown: PID: {} Exitcode: {}'.format(pid, exitcode))
|
||||||
|
|
||||||
|
|
||||||
def make_task(app):
|
def make_task(app):
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
from celery.signals import worker_process_shutdown
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from notifications_utils.recipients import InvalidEmailError
|
from notifications_utils.recipients import InvalidEmailError
|
||||||
from notifications_utils.statsd_decorators import statsd
|
from notifications_utils.statsd_decorators import statsd
|
||||||
@@ -13,11 +12,6 @@ from app.exceptions import NotificationTechnicalFailureException
|
|||||||
from app.models import NOTIFICATION_TECHNICAL_FAILURE
|
from app.models import NOTIFICATION_TECHNICAL_FAILURE
|
||||||
|
|
||||||
|
|
||||||
@worker_process_shutdown.connect
|
|
||||||
def worker_process_shutdown(sender, signal, pid, exitcode):
|
|
||||||
current_app.logger.info('Provider worker shutdown: PID: {} Exitcode: {}'.format(pid, exitcode))
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(bind=True, name="deliver_sms", max_retries=48, default_retry_delay=300)
|
@notify_celery.task(bind=True, name="deliver_sms", max_retries=48, default_retry_delay=300)
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def deliver_sms(self, notification_id):
|
def deliver_sms(self, notification_id):
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from datetime import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
from celery.signals import worker_process_shutdown
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from notifications_utils.statsd_decorators import statsd
|
from notifications_utils.statsd_decorators import statsd
|
||||||
from sqlalchemy import and_, func
|
from sqlalchemy import and_, func
|
||||||
@@ -74,11 +73,6 @@ from app.utils import (
|
|||||||
from app.v2.errors import JobIncompleteError
|
from app.v2.errors import JobIncompleteError
|
||||||
|
|
||||||
|
|
||||||
@worker_process_shutdown.connect
|
|
||||||
def worker_process_shutdown(sender, signal, pid, exitcode):
|
|
||||||
current_app.logger.info('Scheduled tasks worker shutdown: PID: {} Exitcode: {}'.format(pid, exitcode))
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(name="remove_csv_files")
|
@notify_celery.task(name="remove_csv_files")
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def remove_csv_files(job_types):
|
def remove_csv_files(job_types):
|
||||||
|
|||||||
@@ -2,9 +2,7 @@ import json
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from collections import namedtuple, defaultdict
|
from collections import namedtuple, defaultdict
|
||||||
|
|
||||||
from celery.signals import worker_process_shutdown
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
|
||||||
from notifications_utils.recipients import (
|
from notifications_utils.recipients import (
|
||||||
RecipientCSV
|
RecipientCSV
|
||||||
)
|
)
|
||||||
@@ -74,11 +72,6 @@ from app.service.utils import service_allowed_to_send_to
|
|||||||
from app.utils import convert_utc_to_bst
|
from app.utils import convert_utc_to_bst
|
||||||
|
|
||||||
|
|
||||||
@worker_process_shutdown.connect
|
|
||||||
def worker_process_shutdown(sender, signal, pid, exitcode):
|
|
||||||
current_app.logger.info('Tasks worker shutdown: PID: {} Exitcode: {}'.format(pid, exitcode))
|
|
||||||
|
|
||||||
|
|
||||||
@notify_celery.task(name="process-job")
|
@notify_celery.task(name="process-job")
|
||||||
@statsd(namespace="tasks")
|
@statsd(namespace="tasks")
|
||||||
def process_job(job_id):
|
def process_job(job_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user