Merge pull request #13 from Koed00/dev

Adding sphinx build to Travis
This commit is contained in:
Ilan Steemers
2015-07-13 15:36:29 +02:00
10 changed files with 38 additions and 29 deletions
+2 -1
View File
@@ -14,11 +14,12 @@ env:
install: install:
- pip install -q django==$DJANGO - pip install -q django==$DJANGO
- pip install -r requirements.txt - pip install -r requirements.txt
- pip install pytest-django pytz coveralls - pip install pytest-django coveralls sphinx
- python setup.py install - python setup.py install
script: script:
- coverage run --source=django_q -m py.test - coverage run --source=django_q -m py.test
- sphinx-build -b html -d docs/_build/doctrees -nW docs docs/_build/html
after_success: after_success:
- coveralls - coveralls
+2 -1
View File
@@ -5,7 +5,8 @@ myPath = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, myPath) sys.path.insert(0, myPath)
from .tasks import async, schedule, result, fetch from .tasks import async, schedule, result, fetch
from .models import Task, Schedule from .models import Task, Schedule, Success, Failure
from .cluster import Cluster
VERSION = (0, 3, 4) VERSION = (0, 3, 4)
+1 -1
View File
@@ -2,7 +2,7 @@
# #
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = SPHINXOPTS = -nW
SPHINXBUILD = sphinx-build SPHINXBUILD = sphinx-build
PAPER = PAPER =
BUILDDIR = _build BUILDDIR = _build
+1
View File
@@ -1,4 +1,5 @@
.. _admin_page: .. _admin_page:
.. py:currentmodule:: django_q
Admin pages Admin pages
=========== ===========
+7 -5
View File
@@ -1,6 +1,8 @@
Cluster Cluster
======= =======
.. py:currentmodule:: django_q
Django Q uses Python's multiprocessing module to manage a pool of workers that will handle your tasks. Django Q uses Python's multiprocessing module to manage a pool of workers that will handle your tasks.
Start your cluster using Django's `manage.py` command:: Start your cluster using Django's `manage.py` command::
@@ -46,7 +48,7 @@ You can have multiple clusters on multiple machines, working on the same queue a
- They connect to the same Redis server. - They connect to the same Redis server.
- They use the same cluster name. See :ref:`configuration` - They use the same cluster name. See :ref:`configuration`
- They share the same :const:`SECRET_KEY` - They share the same `SECRET_KEY`
Using a Procfile Using a Procfile
---------------- ----------------
@@ -111,7 +113,7 @@ Scheduler
Once a minute the scheduler checks for any scheduled task that should be starting. Once a minute the scheduler checks for any scheduled task that should be starting.
- Creates a task from the schedule - Creates a task from the schedule
- Subtracts 1 from :attr:`Schedule.repeats` - Subtracts 1 from :attr:`django_q.Schedule.repeats`
- Sets the next run time if there are repeats left or if its negative. - Sets the next run time if there are repeats left or if its negative.
.. _stop_procedure: .. _stop_procedure:
@@ -162,7 +164,7 @@ Reference
.. py:attribute:: sentinel .. py:attribute:: sentinel
returns the :class:`multiprocessing.Process` containing the :class:`Sentinel`. returns the :class:`multiprocessing.Process` containing the :ref:`sentinel`.
.. py:attribute:: timeout .. py:attribute:: timeout
@@ -170,11 +172,11 @@ Reference
.. py:attribute:: start_event .. py:attribute:: start_event
A :class:`multiprocessing.Event` indicating if the :class:`Sentinel` has finished starting the cluster A :class:`multiprocessing.Event` indicating if the :ref:`sentinel` has finished starting the cluster
.. py:attribute:: stop_event .. py:attribute:: stop_event
A :class:`multiprocessing.Event` used to instruct the :class:`Sentinel` to initiate the :ref:`stop_procedure` A :class:`multiprocessing.Event` used to instruct the :ref:`sentinel` to initiate the :ref:`stop_procedure`
.. py:attribute:: is_starting .. py:attribute:: is_starting
+1 -1
View File
@@ -100,7 +100,7 @@ exclude_patterns = ['_build']
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
# add_module_names = True add_module_names = False
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
+5 -3
View File
@@ -6,7 +6,7 @@ Installation
$ pip install django-q $ pip install django-q
- Add :mod:`django_q` to :const:`INSTALLED_APPS` in your projects :file:`settings.py`:: - Add :mod:`django_q` to `INSTALLED_APPS` in your projects :file:`settings.py`::
INSTALLED_APPS = ( INSTALLED_APPS = (
# other apps # other apps
@@ -25,7 +25,7 @@ Installation
Configuration Configuration
------------- -------------
Configuration is handled via the :const:`Q_ClUSTER` dictionary in your :file:`settings.py` Configuration is handled via the `Q_ClUSTER` dictionary in your :file:`settings.py`
.. code:: python .. code:: python
@@ -130,7 +130,7 @@ of the cache connection you want to use::
.. tip:: .. tip::
Django Q uses your :const:`SECRET_KEY` to encrypt task packages and prevent task crossover. So make sure you have it set up in your Django settings. Django Q uses your `SECRET_KEY` to encrypt task packages and prevent task crossover. So make sure you have it set up in your Django settings.
Requirements Requirements
------------ ------------
@@ -166,3 +166,5 @@ Django Q is tested for Python 2.7 and 3.4
$ pip install hiredis $ pip install hiredis
This C library maintained by the core Redis team is faster than the standard PythonParser during high loads. This C library maintained by the core Redis team is faster than the standard PythonParser during high loads.
.. py:module:: django_q
+1
View File
@@ -1,5 +1,6 @@
Monitor Monitor
======= =======
.. py:currentmodule::django_q.monitor
The cluster monitor shows information about all the Q clusters connected to your project. The cluster monitor shows information about all the Q clusters connected to your project.
+12 -12
View File
@@ -1,24 +1,24 @@
Schedules Schedules
========= =========
.. py:currentmodule:: django_q
Schedule Schedule
-------- --------
Schedules are regular Django models. You can manage them through the :ref:`admin_page` or directly from your code with the :func:`schedule` function or the :class:`Schedule` model: Schedules are regular Django models.
You can manage them through the :ref:`admin_page` or directly from your code with the :func:`schedule` function or the :class:`Schedule` model:
.. code:: python .. code:: python
from django_q import Schedule, schedule from django_q import Schedule, schedule
# Use the schedule wrapper # Use the schedule wrapper
schedule('math.copysign', schedule('math.copysign',
2, -2, 2, -2,
hook='hooks.print_result', hook='hooks.print_result',
schedule_type=Schedule.DAILY) schedule_type=Schedule.DAILY)
# Or create the object directly # Or create the object directly
Schedule.objects.create(func='math.copysign', Schedule.objects.create(func='math.copysign',
hook='hooks.print_result', hook='hooks.print_result',
args='2,-2', args='2,-2',
@@ -31,24 +31,24 @@ Management Commands
If you want to schedule regular Django management commands, you can use the :mod:`django.core.management` module to make a wrapper function which you can schedule in Django Q:: If you want to schedule regular Django management commands, you can use the :mod:`django.core.management` module to make a wrapper function which you can schedule in Django Q::
# tasks.py # tasks.py
from django.core import management from django.core import management
# wrapping `manage.py clearsessions` # wrapping `manage.py clearsessions`
def clear_sessions_command(): def clear_sessions_command():
return management.call_command('clearsessions') return management.call_command('clearsessions')
# now you can schedule it to run every hour # now you can schedule it to run every hour
from django_q import schedule from django_q import schedule
schedule('tasks.clear_sessions_command', schedule_type='H') schedule('tasks.clear_sessions_command', schedule_type='H')
Reference Reference
--------- ---------
.. py:function:: schedule(func, *args, hook=None, schedule_type='O', repeats=-1, next_run=now() , **kwargs) .. py:function:: schedule(func, *args, hook=None, schedule_type='O', repeats=-1, next_run=now() , **kwargs)
Creates a schedule Creates a schedule
+4 -3
View File
@@ -1,10 +1,11 @@
Tasks Tasks
===== =====
.. py:currentmodule:: django_q
Async Async
----- -----
Use :func:`async` from your code to quickly offload tasks to the :mod:`cluster`: Use :func:`async` from your code to quickly offload tasks to the :class:`Cluster`:
.. code:: python .. code:: python
@@ -83,9 +84,9 @@ Reference
:param func: The task function to execute :param func: The task function to execute
:param args: The arguments for the task function :param args: The arguments for the task function
:type func: str or object :type func: object
:param hook: Optional function to call after execution :param hook: Optional function to call after execution
:type hook: str or object :type hook: object
:param bool sync: If set to True, async will simulate a task execution :param bool sync: If set to True, async will simulate a task execution
:param redis: Optional redis connection :param redis: Optional redis connection
:param kwargs: Keyword arguments for the task function :param kwargs: Keyword arguments for the task function