Allow using a different class for scheduler and worker
See original GitHub issueWould you please make such changes to allow overriding the class used for scheduler and worker?
--- a/huey/consumer.py
+++ b/huey/consumer.py
class Consumer(object):
+
+ scheduler_class = Scheduler
+ worker_class = Worker
+
def __init__(self, huey, workers=1, periodic=True, initial_delay=0.1,
backoff=1.15, max_delay=10.0, utc=True, scheduler_interval=1,
worker_type='thread', check_worker_health=True,
def _create_worker(self):
- return Worker(
+ return self.worker_class(
huey=self.huey,
default_delay=self.default_delay,
max_delay=self.max_delay,
def _create_scheduler(self):
- return Scheduler(
+ return self.scheduler_class(
huey=self.huey,
interval=self.scheduler_interval,
utc=self.utc,
Because currently I have to override Consumer._create_worker
and Consumer._create_scheduler
copying the original implementation and changing the class used which is not DRY and I risk to miss the moment when the original implementation changes.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to schedule apex class after every 5 minutes
Hi, Radhe! I had a similar problem. Try to use Schedule Helper. Allows you to manage your schedules to execute even every 5...
Read more >27. Task Execution and Scheduling - Spring
The simplest method is the one named 'schedule' that takes a Runnable and Date only. That will cause the task to run once...
Read more >Scheduling Jobs - Python RQ
Running a separate rqscheduler CLI command. Worrying about a separate Scheduler class. Running RQ workers with the scheduler component is simple: $ ...
Read more >Lightweight job scheduler extension for Sidekiq - GitHub
hello-scheduler.rb require 'sidekiq-scheduler' class HelloWorld include Sidekiq::Worker def perform puts 'Hello world' end end.
Read more >Schedulers (reactor-core 3.5.1)
public abstract class Schedulers extends Object ... Tasks scheduled with workers of this Scheduler are not guaranteed to run in FIFO order and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I didn’t think it was a good idea at first. After a day I thought it would probably be a fine addition: db68a555080270ff4195ccd861542e7a4164cc6e
It was quite easy to extend Huey in exactly the way you wished. This just makes it even easier – two attributes instead of two methods for the simple case.
I do keep Huey extensible as much as I think is useful. I rely on people who use the library to help find the places where this becomes difficult. Look at the storage backend abstractions – they are extremely amenable to extension or customization.