diff --git a/django_q/cluster.py b/django_q/cluster.py index da7c35a..e88abf3 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -166,6 +166,7 @@ class Sentinel(object): :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)) @@ -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 diff --git a/django_q/migrations/0008_auto_20160224_1026.py b/django_q/migrations/0008_auto_20160224_1026.py new file mode 100644 index 0000000..c9aeef1 --- /dev/null +++ b/django_q/migrations/0008_auto_20160224_1026.py @@ -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), + ), + ] diff --git a/django_q/models.py b/django_q/models.py index ceba5ad..a4b0223 100644 --- a/django_q/models.py +++ b/django_q/models.py @@ -121,7 +121,7 @@ class Failure(Task): 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'")) diff --git a/django_q/tasks.py b/django_q/tasks.py index 4af1788..31690c8 100644 --- a/django_q/tasks.py +++ b/django_q/tasks.py @@ -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 diff --git a/docs/tasks.rst b/docs/tasks.rst index 3fe1373..3bd6eb4 100644 --- a/docs/tasks.rst +++ b/docs/tasks.rst @@ -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. diff --git a/requirements.txt b/requirements.txt index a651585..fb6d0d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 @@ -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