Skip to content

Commit

Permalink
Merge pull request #152 from Koed00/dev
Browse files Browse the repository at this point in the history
Fixes for several issues
  • Loading branch information
Koed00 committed Feb 28, 2016
2 parents 140891b + 681177e commit 52d8d2e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
3 changes: 2 additions & 1 deletion django_q/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def reincarnate(self, process):
:param process: the process to reincarnate
:type process: Process or None
"""
db.connections.close_all() # Close any old connections
if process == self.monitor:
self.monitor = self.spawn_monitor()
logger.error(_("reincarnated monitor {} after sudden death").format(process.name))
Expand Down Expand Up @@ -529,7 +530,7 @@ def scheduler(broker=None):
s.repeats += -1
# send it to the cluster
q_options['broker'] = broker
q_options['group'] = s.name or s.id
q_options['group'] = q_options.get('group', s.name or s.id)
kwargs['q_options'] = q_options
s.task = tasks.async(s.func, *args, **kwargs)
# log it
Expand Down
19 changes: 19 additions & 0 deletions django_q/migrations/0008_auto_20160224_1026.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_q', '0007_ormq'),
]

operations = [
migrations.AlterField(
model_name='schedule',
name='name',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
2 changes: 1 addition & 1 deletion django_q/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Meta:


class Schedule(models.Model):
name = models.CharField(max_length=100, null=True)
name = models.CharField(max_length=100, null=True, blank=True)
func = models.CharField(max_length=256, help_text='e.g. module.tasks.function')
hook = models.CharField(max_length=256, null=True, blank=True, help_text='e.g. module.tasks.result_function')
args = models.TextField(null=True, blank=True, help_text=_("e.g. 1, 2, 'John'"))
Expand Down
4 changes: 2 additions & 2 deletions django_q/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ def async(func, *args, **kwargs):
"""Queue a task for the cluster."""
keywords = kwargs.copy()
opt_keys = ('hook', 'group', 'save', 'sync', 'cached', 'iter_count', 'iter_cached', 'chain', 'broker')
q_options = keywords.pop('q_options', None)
q_options = keywords.pop('q_options', {})
# get an id
tag = uuid()
# build the task package
task = {'id': tag[1],
'name': tag[0],
'name': keywords.pop('task_name', None) or q_options.pop('task_name', None) or tag[0],
'func': func,
'args': args}
# push optionals
Expand Down
5 changes: 5 additions & 0 deletions docs/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ broker
""""""
A broker instance, in case you want to control your own connections.

task_name
"""""""""

Optionally overwrites the auto-generated task name.

q_options
"""""""""
None of the option keywords get passed on to the task function.
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
arrow==0.7.0
blessed==1.14.1
boto3==1.2.3
botocore==1.3.23 # via boto3
boto3==1.2.5
botocore==1.3.30 # via boto3
django-picklefield==0.3.2
django-redis==4.3.0
docutils==0.12 # via botocore
Expand All @@ -16,11 +16,11 @@ hiredis==0.2.0
iron-core==1.2.0 # via iron-mq
iron-mq==0.8
jmespath==0.9.0 # via boto3, botocore
psutil==3.4.2
psutil==4.0.0
pymongo==3.2.1
python-dateutil==2.4.2 # via arrow, botocore, iron-core
redis==2.10.5
requests==2.9.1 # via iron-core, rollbar
rollbar==0.11.2
rollbar==0.11.3
six==1.10.0 # via blessed, python-dateutil, rollbar
wcwidth==0.1.6 # via blessed

0 comments on commit 52d8d2e

Please sign in to comment.