question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow using a different class for scheduler and worker

See original GitHub issue

Would 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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Feb 11, 2019

I didn’t think it was a good idea at first. After a day I thought it would probably be a fine addition: db68a555080270ff4195ccd861542e7a4164cc6e

0reactions
coleifercommented, Feb 11, 2019

Do I understand correctly that … you prefer to keep Huey non-extendable so it can serve mostly your purposes?

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found