Comments (1)
Where are dynamic periodic tasks stored.
This is answered in the very first paragraph of the docs you linked...
To create periodic tasks dynamically we need to register them so that they are added to the in-memory schedule managed by the consumer’s scheduler thread. Since this registry is in-memory, any dynamically defined tasks must be registered within the process that will ultimately schedule them: the consumer.
It is not possible to pass arguments to periodic tasks.
I don't have a good understanding of how Huey works
Yes... to use dynamic periodic tasks you should absolutely understand how Huey works in-and-out because there are lots of gotcha's.
I'm going to skip trying to answer your other questions and just say this... Just about every single time someone asks for dynamic periodic tasks, they are someone with not very much experience or understanding of how this tooling works. They think they've stumbled on some magic recipe that will solve all their problems without realizing that they've simply pushed their problem into a harder place to manage.
The correct way to do what you're asking about, in my opinion, is to persist the user schedules in the database like you would normally. e.g.:
- User 1: 9am cnn headlines
- User 1: 9pm bbc headlines
- User 2: ...
- User 3: ...
Then run a single periodic task every 15 minutes or every hour -- whatever the minimum granularity you want to allow your users to schedule things.
When that single periodic task runs, it will check all the user schedules for the current time and process them. It can delegate to sub-tasks, alternatively, e.g.:
@huey.periodic_task(crontab(minute='0')) # Run every hour, on the hour.
def schedule_messages():
now = datetime.datetime.now()
for user_schedule in UserSchedule.get_list_for_time(now):
fetch_user_schedule(user_schedule)
@huey.task()
def fetch_user_schedule(user_schedule):
# ... fetch headlines or whatever ..
When a user wants to created, edit, or delete their schedule all you need to do is modify the database table. No need to use dynamic periodic tasks.
from huey.
Related Issues (20)
- Store metadata in the task HOT 1
- TypeError: __init__() got an unexpected keyword argument 'ssl' HOT 5
- `result` and `revoke_by_id` differ in their auto-conversion of task_id to str HOT 3
- Question: get last execution by task name HOT 1
- Relation between origin task call and retry call?!? HOT 1
- TaskLockedException('unable to set lock: ...') HOT 1
- Cannot pickle thread.Rlock error HOT 1
- Suggestion for improving `Huey.is_revoked()` documentation
- Inconsistent Time to Enqueue Periodic Tasks HOT 2
- Not scheduled tasks HOT 2
- Huey exits without error HOT 1
- update TODO HOT 1
- Forking ? HOT 3
- How do you feel about a KeyDB implementation? HOT 3
- 'schedule' method for Django Huey task decorated functions is missing HOT 5
- Confirmation: Invoke/Enqueue a task by its string name HOT 1
- Sub 1min intervals HOT 1
- Consumer doesn't pickup updated task HOT 7
- List scheduled period tasks with crontab setup HOT 2
- Retry Tasks on SIGTERM? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from huey.