Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add broker name in Schedule and enhanced Queued Tasks list display admin #502

Merged
merged 3 commits into from Feb 11, 2021

Conversation

telmobarros
Copy link
Contributor

This PR is somehow related to #107 . When we have several queues, the scheduled task is launched by a random queue (what is fine) but the task is also launched to be executed by the same queue what sometimes can delay it if the queue is very busy:

django_q/cluster.py (here)

# Call scheduler once a minute (or so)
  counter += cycle
  if counter >= 30 and Conf.SCHEDULER:
      counter = 0
      scheduler(broker=self.broker)

(and here)

def scheduler(broker: Broker = None):
    """
    Creates a task from a schedule at the scheduled time and schedules next run
    """
    if not broker:
        broker = get_broker()

.....

q_options["broker"] = broker

My PR solves it by assigning a variable 'broker_name' to 'q_options' dict when defining the Schedule Object. If the broker_name refers to an invalid/not running queue it fallbacks to the existing code.

Regardind the enhancement in Queued Tasks list display admin it is simply a filter by key.

@codecov-io
Copy link

codecov-io commented Feb 6, 2021

Codecov Report

Merging #502 (1d6d996) into master (6f0b24c) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
+ Coverage   90.52%   90.54%   +0.01%     
==========================================
  Files          47       47              
  Lines        3082     3088       +6     
==========================================
+ Hits         2790     2796       +6     
  Misses        292      292              
Impacted Files Coverage Δ
django_q/admin.py 98.18% <100.00%> (+0.03%) ⬆️
django_q/cluster.py 91.73% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f0b24c...1d6d996. Read the comment docs.

@Koed00
Copy link
Owner

Koed00 commented Feb 10, 2021

I like it. Would like to see a little snippet in the docs for this to make it easier for other people with the same issue to use.

@telmobarros
Copy link
Contributor Author

Done.

Thank you for your contribution with this amazing tool!

@Koed00 Koed00 merged commit f322eed into Koed00:master Feb 11, 2021
@Koed00
Copy link
Owner

Koed00 commented Feb 11, 2021

Thanks you for your contribution! Without people like you helping out, I couldn't maintain this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants