Skip to content

Commit

Permalink
improving documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Aug 14, 2016
1 parent 67a5ce5 commit c52266a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ clean:
docs:
make -C docs html
@echo "open file://`pwd`/docs/_build/html/index.html"

.PHONY: deploy-docs
deploy-docs: docs
ghp-import -m "update docs" -p docs/_build/html/
7 changes: 5 additions & 2 deletions arq/jobs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
:mod:`jobs`
===========
Defines the ``Job`` class and decedents which deal with encoding and decoding job data.
"""
from datetime import datetime

Expand Down Expand Up @@ -85,9 +87,10 @@ def __repr__(self):

class DatetimeJob(Job):
"""
Alternative Job which
Alternative Job which copes with datetimes. None timezone naïve dates are supported but
the returned datetimes will use python datetime's ``timezone`` class to define the timezone
regardless of the timezone class originally used on the datetime object.
"""

@staticmethod
def msgpack_encoder(obj):
if isinstance(obj, datetime):
Expand Down
2 changes: 2 additions & 0 deletions arq/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
:mod:`main`
===========
Defines the main ``Actor`` class and ``concurrent`` decorator for using arq from within your code.
"""
import inspect
import logging
Expand Down
8 changes: 8 additions & 0 deletions arq/testing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
"""
:mod:`testing`
==============
pytest plugin and other utilities useful when writing tests for code using arq.
include the plugin in your tests's `conftest.py` file with::
pytest_plugins = 'arq.testing'
See arq's own tests for examples of usage.
"""
import asyncio
import contextlib
Expand Down
6 changes: 4 additions & 2 deletions arq/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
:mod:`utilities`
================
:mod:`utils`
============
Utilises for running arq used by modules.
"""
import asyncio
import base64
Expand Down
15 changes: 14 additions & 1 deletion arq/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
:mod:`worker`
=============
Responsible for executing jobs in the worker processes.
"""
import asyncio
import logging
Expand Down Expand Up @@ -310,7 +312,15 @@ def import_string(file_path, attr_name):
return attr


def start_worker(worker_path, worker_class, burst, loop=None):
def start_worker(worker_path: str, worker_class: str, burst: bool, loop: asyncio.AbstractEventLoop=None):
"""
Run from within the subprocess to load the worker class and execute jobs.
:param worker_path: full path to the python file containing the worker definition
:param worker_class: name of the worker class to be loaded and used
:param burst: whether or not to run in burst mode
:param loop: asyncio loop use to or None
"""
worker_cls = import_string(worker_path, worker_class)
worker = worker_cls(burst=burst, loop=loop)
work_logger.info('Starting %s on worker process pid=%d', worker_cls.__name__, os.getpid())
Expand All @@ -327,6 +337,9 @@ def start_worker(worker_path, worker_class, burst, loop=None):


class RunWorkerProcess:
"""
Responsible for starting a process to run the worker, monitoring it and possibly killing it.
"""
def __init__(self, worker_path, worker_class, burst=False):
signal.signal(signal.SIGINT, self.handle_sig)
signal.signal(signal.SIGTERM, self.handle_sig)
Expand Down
17 changes: 15 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_theme_options = {
'github_user': 'samuelcolvin',
'github_repo': 'arq',
'travis_button': True,
'codecov_button': True,
'page_width': '1200px',
'github_banner': True,

'github_type': 'star',
}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down Expand Up @@ -184,7 +193,11 @@
# Custom sidebar templates, maps document names to template names.
#
html_sidebars = {
'**': ['localtoc.html', 'searchbox.html'],
'**': [
'about.html',
'localtoc.html',
'searchbox.html',
]
}

# Additional templates that should be rendered to pages, maps page names to
Expand Down
8 changes: 2 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ arq
.. toctree::
:maxdepth: 2

|Build Status| |Coverage| |pypi| |license|
|pypi| |license|


Job queues in python with asyncio, redis and msgpack.
Expand Down Expand Up @@ -61,7 +61,7 @@ API Reference
:members:

.. automodule:: arq.jobs
:members:
:members: Job, DatetimeJob

.. automodule:: arq.logs
:members:
Expand All @@ -79,10 +79,6 @@ Indices and tables
* :ref:`modindex`
* :ref:`search`

.. |Build Status| image:: https://travis-ci.org/samuelcolvin/arq.svg?branch=master
:target: https://travis-ci.org/samuelcolvin/arq
.. |Coverage| image:: https://codecov.io/gh/samuelcolvin/arq/branch/master/graph/badge.svg
:target: https://codecov.io/gh/samuelcolvin/arq
.. |pypi| image:: https://img.shields.io/pypi/v/arq.svg
:target: https://pypi.python.org/pypi/arq
.. |license| image:: https://img.shields.io/pypi/l/arq.svg
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ coverage
docutils
flake8
isort
ghp-import
pep8
pytest
pytest-cov
Expand Down

0 comments on commit c52266a

Please sign in to comment.