Skip to content

Instantly share code, notes, and snippets.

@PeterJCLaw
Created October 9, 2020 12:10
Show Gist options
  • Select an option

  • Save PeterJCLaw/dd53c4ea1ab96b11f5c9814511552ec8 to your computer and use it in GitHub Desktop.

Select an option

Save PeterJCLaw/dd53c4ea1ab96b11f5c9814511552ec8 to your computer and use it in GitHub Desktop.
Helper for finding DLQ crons which run at a given time
from django_lightweight_queue.cron_scheduler import get_cron_config
cc = get_cron_config()
crons_then = set()
for x in cc:
for hour in (22, 23, 0):
for minute in range(3):
if (
x['hour_matcher'](hour) and
x['min_matcher'](minute)
):
# print(x)
crons_then.add(
'{command}({command_args}, {command_kwargs}):{queue} | {hours} : {minutes}'.format(
command=x['command'],
command_args=repr(x.get('command_args')),
command_kwargs=repr(x.get('command_kwargs')),
queue=x.get('queue'),
hours=x.get('hours'),
minutes=x.get('minutes'),
),
)
break
print("\n".join(repr(x) for x in sorted(crons_then)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment