How to use the huey.contrib.djhuey.HUEY function in huey

To help you get started, we’ve selected a few huey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sci-wms / sci-wms / wms / tasks.py View on Github external
def update_grid_cache(pkey):
    with HUEY.lock_task('grid-cache-{}'.format(pkey)):
        try:
            d = Dataset.objects.get(pk=pkey)
            d.update_grid_cache()
            return 'Updated {} ({!s})'.format(d.name, d.pk)
        except Dataset.DoesNotExist:
            return 'Dataset did not exist, can not complete task'
        except AttributeError:
            return 'No update_grid_cache method on this dataset'
github sci-wms / sci-wms / wms / tasks.py View on Github external
def update_layers(pkey):
    with HUEY.lock_task('process-{}'.format(pkey)):
        try:
            d = Dataset.objects.get(pk=pkey)
            d.update_layers()
            return 'Processed {} ({!s})'.format(d.name, d.pk)
        except Dataset.DoesNotExist:
            return 'Dataset did not exist, can not complete task'
        except AttributeError:
            return 'No update_layers method on this dataset'
github st-tu-dresden / inloop / inloop / gitload / tasks.py View on Github external
def load_tasks_async():
    with HUEY.lock_task('import-lock'):
        load_tasks(GitRepository(
            settings.REPOSITORY_ROOT,
            url=config.GITLOAD_URL,
            branch=config.GITLOAD_BRANCH
        ))
github oTree-org / otree-core / otree_startup / asgi.py View on Github external
configure_settings()
    django.setup()

application = get_default_application()

# clear any tasks in Huey DB, so they don't pile up over time,
# especially if you run the server without the timeoutworker to consume the
# tasks.
# ideally we would only schedule a task in Huey if timeoutworker is running,
# so that we don't pile up messages that never get consumed, but I don't know
# how and when to check if Huey is running, in a performant way.
# this code is also in timeoutworker.
from huey.contrib.djhuey import HUEY  # noqa
import redis.exceptions
try:
    HUEY.flush()
except redis.exceptions.ConnectionError:
    # maybe Redis is not running
    pass
github scoutapp / scout_apm_python / src / scout_apm / django / instruments / huey.py View on Github external
if instrumented:
        return
    instrumented = True

    # Avoid importing if not installed
    if "huey.contrib.djhuey" not in settings.INSTALLED_APPS:  # pragma: no cover
        return

    try:
        from huey.contrib.djhuey import HUEY
    except ImportError:  # pragma: no cover
        return

    from scout_apm.huey import attach_scout_handlers

    attach_scout_handlers(HUEY)
    logger.debug("Instrumented huey.contrib.djhuey")
github oTree-org / otree-core / otree / management / commands / timeoutworkeronly.py View on Github external
def handle(self, *args, **options):
        # clear any tasks in Huey DB, so they don't pile up over time,
        # especially if you run the server without the timeoutworker to consume
        # the tasks.
        # this code is also in asgi.py. it should be in both places,
        # to ensure the database is flushed in all circumstances.
        from huey.contrib.djhuey import HUEY

        HUEY.flush()
        # need to set USE_REDIS = True, because it uses the test client
        # to submit pages, and if the next page has a timeout as well,
        # its timeout task should be queued.
        import otree.common

        otree.common.USE_REDIS = True
        super().handle(*args, **options)
github oTree-org / otree-core / otree / common.py View on Github external
def get_redis_conn():
    '''reuse Huey Redis connection'''
    return HUEY.storage.conn
github oTree-org / otree-core / otree / common_internal.py View on Github external
def get_redis_conn():
    '''reuse Huey Redis connection'''
    return HUEY.storage.conn