Example #1
0
 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()
     super(Command, self).handle(*args, **options)
Example #2
0
 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()
     super(Command, self).handle(*args, **options)
Example #3
0
 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_internal
     otree.common_internal.USE_REDIS = True
     super().handle(*args, **options)
    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

        if not os.environ.get('REDIS_URL'):
            sys.exit('REDIS_URL env var must be defined')

        try:
            HUEY.flush()
        except redis.exceptions.ConnectionError as exc:
            sys.exit(f'Could not connect to Redis: {exc}')

        super().handle(*args, **options)
Example #5
0
import os
import django
from channels.routing import get_default_application
from . import configure_settings
from django.conf import settings

# needed if uvicorn is launched multi-process
if not settings.configured:
    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
 def handle(self, *args, **kwargs):
     HUEY.pending_count()
     HUEY.flush()
     Entry.objects.all().delete()
Example #7
0
import os
import channels.asgi
from . import configure_settings

configure_settings()
channel_layer = channels.asgi.get_channel_layer()

from otree.common_internal import (
    release_any_stale_locks, get_redis_conn  # noqa
)

# 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
HUEY.flush()

from otree.bots.browser import redis_flush_bots  # noqa
redis_flush_bots(get_redis_conn())

# needs to happen after Django setup
release_any_stale_locks()
Example #8
0
 def post(self, request):
     HUEY.flush()
     messages.success(request, 'The task queue has been flushed.')
     return redirect('admin:index')