mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-09 21:20:56 +08:00
adds global sync configuration option
Setting the `sync` configuration option will force all async() calls to be run with `sync=True`. Useful for testing.
This commit is contained in:
@@ -74,6 +74,9 @@ class Conf(object):
|
|||||||
# Sets the number of processors for each worker, defaults to all.
|
# Sets the number of processors for each worker, defaults to all.
|
||||||
CPU_AFFINITY = conf.get('cpu_affinity', 0)
|
CPU_AFFINITY = conf.get('cpu_affinity', 0)
|
||||||
|
|
||||||
|
# Global sync option to for debugging
|
||||||
|
SYNC = conf.get('sync', False)
|
||||||
|
|
||||||
# Use the secret key for package signing
|
# Use the secret key for package signing
|
||||||
# Django itself should raise an error if it's not configured
|
# Django itself should raise an error if it's not configured
|
||||||
SECRET_KEY = settings.SECRET_KEY
|
SECRET_KEY = settings.SECRET_KEY
|
||||||
|
|||||||
+1
-1
@@ -39,7 +39,7 @@ def async(func, *args, **kwargs):
|
|||||||
task['save'] = save
|
task['save'] = save
|
||||||
# sign it
|
# sign it
|
||||||
pack = signing.SignedPackage.dumps(task)
|
pack = signing.SignedPackage.dumps(task)
|
||||||
if sync:
|
if sync or Conf.SYNC:
|
||||||
return _sync(pack)
|
return _sync(pack)
|
||||||
# push it
|
# push it
|
||||||
redis.rpush(list_key, pack)
|
redis.rpush(list_key, pack)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
.. py:currentmodule:: django_q
|
||||||
|
|
||||||
- Install the latest version with pip::
|
- Install the latest version with pip::
|
||||||
|
|
||||||
@@ -93,6 +94,12 @@ Limits the amount of successful tasks saved to Django.
|
|||||||
|
|
||||||
.. _queue_limit:
|
.. _queue_limit:
|
||||||
|
|
||||||
|
sync
|
||||||
|
~~~~
|
||||||
|
|
||||||
|
When set to ``True`` this configuration option forces all :func:`async` calls to be run with ``sync=True``.
|
||||||
|
Effectively making everything synchronous. Useful for testing. Defaults to ``False``.
|
||||||
|
|
||||||
queue_limit
|
queue_limit
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user