Example #1
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)

        if hasattr(settings, 'OPBEAT'):
            from opbeat.contrib.django.models import client as opbeat_client
            from opbeat.contrib.django.models import logger as opbeat_logger
            from opbeat.contrib.django.models import register_handlers as opbeat_register_handlers
            from opbeat.contrib.celery import register_signal as opbeat_register_signal

            try:
                opbeat_register_signal(opbeat_client)
            except Exception as e:
                opbeat_logger.exception('Failed installing celery hook: %s' % e)

            if 'opbeat.contrib.django' in settings.INSTALLED_APPS:
                opbeat_register_handlers()
Example #2
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
    
            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN'])
            raven_register_signal(raven_client)
    def ready(self):
        installed_apps = [app_config.name for app_config in apps.get_app_configs()]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration

            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal


            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['dsn'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)
Example #4
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        installed_apps = [app_config.name for app_config in apps.get_app_configs()]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)
Example #5
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        installed_apps = [app_config.name for app_config in apps.get_app_configs()]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration

            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal


            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['dsn'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)
Example #6
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        installed_apps = [
            app_config.name for app_config in apps.get_app_configs()
        ]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            # Since raven is required in production only,
            # imports might (most surely will) be wiped out
            # during PyCharm code clean up started
            # in other environments.
            # @formatter:off
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal
            # @formatter:on

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)

        if hasattr(settings, 'OPBEAT'):
            # Since opbeat is required in production only,
            # imports might (most surely will) be wiped out
            # during PyCharm code clean up started
            # in other environments.
            # @formatter:off
            from opbeat.contrib.django.models import client as opbeat_client
            from opbeat.contrib.django.models import logger as opbeat_logger
            from opbeat.contrib.django.models import register_handlers as opbeat_register_handlers
            from opbeat.contrib.celery import register_signal as opbeat_register_signal
            # @formatter:on

            try:
                opbeat_register_signal(opbeat_client)
            except Exception as e:
                opbeat_logger.exception(f'Failed installing celery hook: {e}')

            if 'opbeat.contrib.django' in settings.INSTALLED_APPS:
                opbeat_register_handlers()
Example #7
0
    def ready(self):
        installed_apps = [app_config.name for app_config in apps.get_app_configs()]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
# Since raven is required in production only,
            # imports might (most surely will) be wiped out
            # during PyCharm code clean up started
            # in other environments.
            # @formatter:off
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal
# @formatter:on

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['dsn'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)
Example #8
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings')
        installed_apps = [app_config.name for app_config in apps.get_app_configs()]  # pragma: no cover
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
# Since raven is required in production only,
            # imports might (most surely will) be wiped out
            # during PyCharm code clean up started
            # in other environments.
            # @formatter:off
            from raven import Client as RavenClient  # pragma: no cover
            from raven.contrib.celery import register_signal as raven_register_signal  # pragma: no cover
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal  # pragma: no cover
# @formatter:on

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['dsn'])  # pragma: no cover
            raven_register_logger_signal(raven_client)  # pragma: no cover
            raven_register_signal(raven_client)  # pragma: no cover
Example #9
0
    def ready(self):
        # Using a string here means the worker don't have to serialize
        # the configuration object to child processes.
        # - namespace='CELERY' means all celery-related configuration keys
        #   should have a `CELERY_` prefix.

        app.config_from_object('django.conf:settings', namespace='CELERY')

        app.autodiscover_tasks(lambda: settings.INSTALLED_APPS, force=True)

        app.conf.update(
            result_backend='rpc://',
            result_expires=3600,
        )

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['dsn'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)

        if hasattr(settings, 'OPBEAT'):
            from opbeat.contrib.django.models import client as opbeat_client
            from opbeat.contrib.django.models import logger as opbeat_logger
            from opbeat.contrib.django.models import register_handlers as opbeat_register_handlers
            from opbeat.contrib.celery import register_signal as opbeat_register_signal

            try:
                opbeat_register_signal(opbeat_client)
            except Exception as e:
                opbeat_logger.exception('Failed installing celery hook: %s' % e)

            if 'opbeat.contrib.django' in settings.INSTALLED_APPS:
                opbeat_register_handlers()
Example #10
0
        {% if cookiecutter.use_sentry == 'y' -%}
        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
{% if cookiecutter.use_pycharm == 'y' -%}
	    # Since raven is required in production only,
            # imports might (most surely will) be wiped out
            # during PyCharm code clean up started
            # in other environments.
            # @formatter:off
{%- endif %}
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal
{% if cookiecutter.use_pycharm == 'y' -%}
            # @formatter:on
{%- endif %}

            raven_client = RavenClient(dsn=settings.RAVEN_CONFIG['DSN'])
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)
        {%- endif %}


@app.task(bind=True)
def debug_task(self):
    print(f'Request: {self.request!r}')  # pragma: no cover
{% else %}
# Use this as a starting point for your project with celery.
# If you are not using celery, you can remove this app
{% endif -%}
Example #11
0
 def on_configure(self):
     if os.environ.get("SENTRY_DSN") is not None:
         client = raven.Client(os.environ.get("SENTRY_DSN"))
         raven_register_logger_signal(client)
         raven_register_signal(client)
Example #12
0
    def ready(self):
        # Using a string here means the worker will not have to
        # pickle the object when using Windows.
        app.config_from_object('django.conf:settings', namespace='CELERY')
        app.conf.timezone = settings.TIME_ZONE
        app.conf.ONCE = {
            'backend': 'celery_once.backends.Redis',
            'settings': {
                'url': settings.REDIS_LOCATION,
                'default_timeout': 60 * 60
            }
        }

        app.conf.beat_schedule = {
            'users_notify_inactivity_session': {
                'task': 'his.users.tasks.notify_inactivity_session',
                'schedule': crontab()  # execute every minute
            },
            'core_create_real_order_and_end_plan_item': {
                'task': 'his.core.tasks.create_real_order_and_end_plan_item',
                'schedule': crontab(minute=0, hour=0)
            }
        }

        if 'ADM' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['ADM_bill_room_items'] = {
                'task': 'his.apps.ADM.tasks.bill_room_items',
                'schedule': crontab(hour=23, minute=55)
            }

        if 'INF' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['inbound_interface_product'] = {
                'task': 'his.apps.INF.tasks.inbound_interface_product',
                'schedule': crontab(minute='*/5')
            }
            app.conf.beat_schedule['inbound_interface_stock'] = {
                'task': 'his.apps.INF.tasks.inbound_interface_stock',
                'schedule': crontab(minute='*/5')
            }
            app.conf.beat_schedule['inbound_interface_movement'] = {
                'task': 'his.apps.INF.tasks.inbound_interface_movement',
                'schedule': crontab(minute='*/5')
            }
            app.conf.beat_schedule['inbound_interface_hr'] = {
                'task': 'his.apps.INF.tasks.inbound_interface_hr',
                'schedule': crontab(minute='*/5')
            }
            app.conf.beat_schedule['outbound_interface_patient_record'] = {
                'task': 'his.apps.INF.tasks.outbound_interface_patient_record',
                'schedule': crontab(hour=1, minute=0)
            }
            app.conf.beat_schedule['outbound_interface_staging'] = {
                'task': 'his.apps.INF.tasks.outbound_interface_staging',
                'schedule': crontab(hour=1, minute=30)
            }
            app.conf.beat_schedule['outbound_interface_drug_dispensing'] = {
                'task':
                'his.apps.INF.tasks.outbound_interface_drug_dispensing',
                'schedule': crontab(hour=0, minute=0)
            }
            app.conf.beat_schedule['outbound_interface_drug_transfer'] = {
                'task': 'his.apps.INF.tasks.outbound_interface_drug_transfer',
                'schedule': crontab(hour=23, minute=0)
            }
            app.conf.beat_schedule['outbound_interface_supply_dispensing'] = {
                'task':
                'his.apps.INF.tasks.outbound_interface_supply_dispensing',
                'schedule': crontab(hour=0, minute=0)
            }
            app.conf.beat_schedule['generate_send_claim_data'] = {
                'task': 'his.apps.INF.tasks.generate_send_claim_data',
                'schedule': crontab(hour=0, minute=5)
            }

        if 'FLM' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['check_expired_queue_flow_transaction'] = {
                'task':
                'his.apps.FLM.tasks.check_expired_queue_flow_transaction',
                'schedule': crontab(hour=0, minute=10)
            }

        if 'HRM' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['HRM_reject_broadcast_and_offer'] = {
                'task': 'his.apps.HRM.tasks.reject_broadcast_and_offer',
                'schedule': crontab(hour=0, minute=0)
            }

        if 'appointment' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['penta_create_provider_available_slot'] = {
                'task':
                'his.penta.appointment.tasks.create_provider_available_slot',
                'schedule': crontab(day_of_month=25)
            }

        if 'REG' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['check_certified_death_document'] = {
                'task': 'his.apps.REG.tasks.check_certified_death_document',
                'schedule': crontab(minute='*/30')
            }

        if 'DPO' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['email_notifications'] = {
                'task':
                'his.apps.DPO.tasks.email_notifications',
                'schedule':
                crontab(hour=config.core_EMAIL_NOTIFICATION_TIME, minute=0)
            }

        if 'LAB' in settings.DJANGO_INCLUDE_APPS:
            app.conf.beat_schedule['LAB_send_set_lab_order'] = {
                'task': 'his.apps.LAB.tasks.send_set_lab_order',
                'schedule': crontab()  # execute every minute
            }

        installed_apps = [
            app_config.name for app_config in apps.get_app_configs()
        ]
        app.autodiscover_tasks(lambda: installed_apps, force=True)

        if hasattr(settings, 'RAVEN_CONFIG'):
            # Celery signal registration
            from raven import Client as RavenClient
            from raven.contrib.celery import register_signal as raven_register_signal
            from raven.contrib.celery import register_logger_signal as raven_register_logger_signal

            raven_client = RavenClient(
                dsn=settings.RAVEN_CONFIG['DSN'],
                release=settings.RAVEN_CONFIG.get('release'),
                site=settings.RAVEN_CONFIG.get('site'),
                ignore_exceptions=settings.RAVEN_CONFIG.get(
                    'ignore_exceptions'))
            raven_register_logger_signal(raven_client)
            raven_register_signal(raven_client)