dabapps / django-db-queue Goto Github PK
View Code? Open in Web Editor NEWSimple database-backed job queue
License: BSD 2-Clause "Simplified" License
Simple database-backed job queue
License: BSD 2-Clause "Simplified" License
Would you consider adding a nullable ForeignKey field to store the user that a job belongs to?
class Job(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True, related_name='jobs')
...
It would then be possible to assign users to jobs within views that create them, or from any other context in which the user is known:
def my_view(request):
job = Job.objects.create(name='my_job', user=request.user)
...
I realize I can subclass Job
and add it myself:
class JobWithUser(Job):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='jobs')
However, it would be more convenient for anyone who wants this functionality if it were available out-of-the-box.
Hi,
Firstly, thank you for sharing this app - I heard Jamie mention it on DjangoChat a while back.
I'm now looking to use it and I wonder if you can help me.
I have my django app running in a shared env (Hostpresto) under Phusion passenger and I want to add 'django-db-queue' to manage periodic tasks. The hosting team suggest setting up a cron job to to run. manage.py worker
periodically.
Q1: Do you have any experience of deploying this app into a cpanel /shared env, if so how did you make it work?
Q2: In your opinion, is using cron to run manage.py worker
a reasonable approach.
Thoughts?
Rob
Can django model utils version be greater than 2.3.1 without breaking anything ? In the application I am developing I have a strict requirement for django model utils at least 3.x.x
Current Job
creation depends on .save() to be called, as a result processing jobs created using bulk_create
causes django-level exceptions.
Either the Query manager should be overridden to return UnsupportedOperation
or the code refactored to work with bulk_create
As is
self.stdout.write( 'Starting job worker for queue "%s" with rate limit %s/s' % (queue_name, rate_limit_in_seconds) )
proposed
``self.stdout.write(
'Starting job worker for queue "%s" with rate limit of one job per %s second(s)'
% (queue_name, rate_limit_in_seconds)
)
`
If you're ok with the wording, I'm happy to submit a Pull request to correct this.
When running py manage.py worker
on Windows, I get the following:
AttributeError: module 'signal' has no attribute 'SIGQUIT'
Which is coming from here:
I was able to successfully run the worker and create jobs by modifying it like this:
if hasattr(signal, 'SIGQUIT'):
signal.signal(signal.SIGQUIT, self.shutdown)
Would be great if there was a possibility to launch a Worker process that terminates when no more jobs are available so that a worker can be launched from a Cron or scheduler periodically
something like "--non-persistent" command line option
The readme says jobs should be in the format
{
'my_job': ['project.common.jobs.my_task'],
}
But the code (1.2) errors out unless it's in the format...
{
'my_job': {
'tasks': ['project.common.jobs.my_task'],
}
}
Haven't investigated this at all yet, but..
$ env/bin/pip install django-db-queue
Downloading/unpacking django-db-queue
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django-db-queue
Cleaning up...
No distributions at all found for django-db-queue
Storing debug log for failure in /Users/jamie/.pip/pip.log
cc @weargoggles
Nice library, thanks for all the work! Would be useful to have a GUI view of Job
s showing which ones are queued up to run and when, and which ones have been run.
Failing to run create_job command with either --queue_name
or --workspace
args :
python manage.py create_job test_web_api --queue_name not_default
manage.py create_job: error: unrecognized arguments: not_default
python manage.py create_job test_web_api --worskpace '{"key": "value"}'
manage.py create_job: error: unrecognized arguments: --worskpace {"key": "value"}
I think it may work by changing the action
parameter for argparse from store_true
to store
:
# create_job.py Command.add_arguments()
def add_arguments(self, parser):
parser.add_argument("args", nargs="+")
parser.add_argument(
"--workspace",
action="store", # is currently "store_true"
dest="workspace",
default=None,
help="JSON-formatted initial commandworkspace.",
)
parser.add_argument(
"--queue_name",
action="store", # is currently "store_true"
dest="queue_name",
default=None,
help="A specific queue to add this job to",
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.