You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why do Huey schedules tables and Huey tasks not auto-populating?
Here I declared the periodic and non-periodic tasks, I expected them to be recorded in the orm.
settings.py
# avryhof / huey_django_orm
INSTALLED_APPS.extend(['huey.contrib.djhuey', 'huey_django_orm'])
HUEY = {
'huey_class': 'huey_django_orm.storage.DjangoORMHuey',
'name': DATABASES['default']['NAME'], # Use db name for huey.
'results': True, # Store return values of tasks.
'store_none': False, # If a task returns None, do not save to results.
'immediate': DEBUG, # If DEBUG=True, run synchronously. (FALSE)
'utc': True, # Use UTC for all times internally.
'compression': True, # Compress tasks and result data.
'use_zlib': True, # Use zlib for compression instead of gzip.
'consumer': {
'workers': 4,
'worker_type': 'thread',
'initial_delay': 0.1, # Smallest polling interval, same as -d.
'backoff': 1, # Exponential backoff using this rate, -b.
'max_delay': 5, # Max possible polling interval, -m.
'scheduler_interval': 1, # Check schedule every second, -s.
'periodic': True, # Enable crontab feature.
'check_worker_health': True, # Enable worker health checks.
'health_check_interval': 1, # Check worker health every second.
},
}
tasks.py
from test_app.models import Person
from datetime import datetime
from huey import crontab
from huey.contrib.djhuey import db_periodic_task, db_task, lock_task
@db_periodic_task(crontab())
@lock_task('create-lock') # Goes *after* the task decorator.
def create():
print(f"Executing create ...")
name = datetime.now().strftime('%Y-%m-%d %H:%M')
obj = Person.objects.create(name=name)
# Generate database backup. Since this may take longer than an
# hour, we want to ensure that it is not run concurrently.
with lock_task('get-lock'):
get(name)
print(f"Finish create for object {obj.name} ...")
@db_task()
def get(name):
print(f"Executing get ...")
obj = Person.objects.get(name=name)
print(f"Finish get for object {obj.name} ...")
@db_periodic_task(crontab())
@lock_task('count-lock') # Goes *after* the task decorator.
def count():
print(f"Executing count ...")
objs = Person.objects.count()
print(f"Finish count {objs} ...")
The text was updated successfully, but these errors were encountered:
Why do Huey schedules tables and Huey tasks not auto-populating?
Here I declared the periodic and non-periodic tasks, I expected them to be recorded in the orm.
settings.py
tasks.py
The text was updated successfully, but these errors were encountered: