celery-redis-sentinel
Advanced tools
| # -*- coding: utf-8 -*- | ||
| from __future__ import absolute_import, print_function, unicode_literals | ||
| from celery import Task | ||
| from .redis_sentinel import ensure_redis_call | ||
| class EnsuredRedisTask(Task): | ||
| """ | ||
| Abstract celery task subclass which provides same functionality as | ||
| :py:class:`ensure_redis_call <celery_redis_sentinel.redis_sentinel.ensure_redis_call>` | ||
| except it is added at task definition time instead of during task schedule call. | ||
| This task subclass can be provided during task definition | ||
| by using ``base`` parameter. | ||
| Examples | ||
| -------- | ||
| :: | ||
| @app.task(base=EnsuredRedisTask) | ||
| def add(a, b): | ||
| return a + b | ||
| """ | ||
| abstract = True | ||
| def apply_async(self, *args, **kwargs): | ||
| _super = super(EnsuredRedisTask, self).apply_async | ||
| return ensure_redis_call(_super, *args, **kwargs) |
| celery_redis_sentinel.task module | ||
| ================================= | ||
| .. automodule:: celery_redis_sentinel.task | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
| # -*- coding: utf-8 -*- | ||
| from __future__ import absolute_import, print_function, unicode_literals | ||
| import mock | ||
| from celery_redis_sentinel.task import EnsuredRedisTask | ||
| @mock.patch('celery_redis_sentinel.task.ensure_redis_call') | ||
| def test_apply_async(mock_ensure_redis_call): | ||
| task = EnsuredRedisTask() | ||
| actual = task.apply_async('foo', happy='rainbows') | ||
| assert actual == mock_ensure_redis_call.return_value | ||
| mock_ensure_redis_call.assert_called_once_with(mock.ANY, 'foo', happy='rainbows') |
| Metadata-Version: 1.1 | ||
| Name: celery-redis-sentinel | ||
| Version: 0.1.0 | ||
| Version: 0.2.0 | ||
| Summary: Celery broker and results backend implementation for Redis Sentinel | ||
@@ -110,12 +110,27 @@ Home-page: https://github.com/dealertrack/celery-redis-sentinel | ||
| Alternatively you can use a supplied abstract celery task subclass which provides | ||
| same retrying behavior in the task definition itself:: | ||
| # tasks.py | ||
| from celery_redis_sentinel.tasks import EnsuredRedisTask | ||
| @app.task(base=EnsuredRedisTask) | ||
| def add(a, b): | ||
| return a + b | ||
| History | ||
| ------- | ||
| Master (not yet on PyPI) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 0.2 (2016-01-14) | ||
| ~~~~~~~~~~~~~~~~ | ||
| * **New**: Added ``EnsuredRedisTask`` which allows to ensure tasks are scheduled | ||
| via an abstract base task class in task definition rather then explicitly using | ||
| ``ensure_redis_call`` while calling the task:: | ||
| @app.task(base=EnsuredRedisTask) | ||
| def foo(): pass | ||
@@ -155,3 +170,3 @@ 0.1 (2016-01-13) | ||
| Copyright © 2015, dealertrack technologies | ||
| Copyright © 2015-2016, dealertrack technologies | ||
@@ -177,3 +192,2 @@ :: | ||
| THE SOFTWARE. | ||
| Keywords: celery redis sentinel broker results | ||
@@ -180,0 +194,0 @@ Platform: UNKNOWN |
@@ -13,2 +13,3 @@ AUTHORS.rst | ||
| celery_redis_sentinel/register.py | ||
| celery_redis_sentinel/task.py | ||
| celery_redis_sentinel/transport.py | ||
@@ -27,2 +28,3 @@ celery_redis_sentinel.egg-info/PKG-INFO | ||
| docs/api/celery_redis_sentinel.rst | ||
| docs/api/celery_redis_sentinel.task.rst | ||
| docs/api/celery_redis_sentinel.transport.rst | ||
@@ -34,2 +36,3 @@ docs/api/modules.rst | ||
| tests/test_register.py | ||
| tests/test_task.py | ||
| tests/test_transport.py |
@@ -6,3 +6,3 @@ # -*- coding: utf-8 -*- | ||
| __author__ = 'Miroslav Shubernetskiy' | ||
| __version__ = '0.1.0' | ||
| __version__ = '0.2.0' | ||
@@ -9,0 +9,0 @@ try: |
@@ -17,3 +17,4 @@ celery_redis_sentinel package | ||
| celery_redis_sentinel.register | ||
| celery_redis_sentinel.task | ||
| celery_redis_sentinel.transport | ||
+10
-0
@@ -9,4 +9,14 @@ .. :changelog: | ||
| In Progress | ||
| 0.2 (2016-01-14) | ||
| ~~~~~~~~~~~~~~~~ | ||
| * **New**: Added ``EnsuredRedisTask`` which allows to ensure tasks are scheduled | ||
| via an abstract base task class in task definition rather then explicitly using | ||
| ``ensure_redis_call`` while calling the task:: | ||
| @app.task(base=EnsuredRedisTask) | ||
| def foo(): pass | ||
| 0.1 (2016-01-13) | ||
@@ -13,0 +23,0 @@ ~~~~~~~~~~~~~~~~ |
+1
-1
@@ -6,3 +6,3 @@ License | ||
| Copyright © 2015, dealertrack technologies | ||
| Copyright © 2015-2016, dealertrack technologies | ||
@@ -9,0 +9,0 @@ :: |
+19
-5
| Metadata-Version: 1.1 | ||
| Name: celery-redis-sentinel | ||
| Version: 0.1.0 | ||
| Version: 0.2.0 | ||
| Summary: Celery broker and results backend implementation for Redis Sentinel | ||
@@ -110,12 +110,27 @@ Home-page: https://github.com/dealertrack/celery-redis-sentinel | ||
| Alternatively you can use a supplied abstract celery task subclass which provides | ||
| same retrying behavior in the task definition itself:: | ||
| # tasks.py | ||
| from celery_redis_sentinel.tasks import EnsuredRedisTask | ||
| @app.task(base=EnsuredRedisTask) | ||
| def add(a, b): | ||
| return a + b | ||
| History | ||
| ------- | ||
| Master (not yet on PyPI) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 0.2 (2016-01-14) | ||
| ~~~~~~~~~~~~~~~~ | ||
| * **New**: Added ``EnsuredRedisTask`` which allows to ensure tasks are scheduled | ||
| via an abstract base task class in task definition rather then explicitly using | ||
| ``ensure_redis_call`` while calling the task:: | ||
| @app.task(base=EnsuredRedisTask) | ||
| def foo(): pass | ||
@@ -155,3 +170,3 @@ 0.1 (2016-01-13) | ||
| Copyright © 2015, dealertrack technologies | ||
| Copyright © 2015-2016, dealertrack technologies | ||
@@ -177,3 +192,2 @@ :: | ||
| THE SOFTWARE. | ||
| Keywords: celery redis sentinel broker results | ||
@@ -180,0 +194,0 @@ Platform: UNKNOWN |
+10
-0
@@ -101,1 +101,11 @@ ===================== | ||
| ensure_redis_call(add.delay, 1, 2) | ||
| Alternatively you can use a supplied abstract celery task subclass which provides | ||
| same retrying behavior in the task definition itself:: | ||
| # tasks.py | ||
| from celery_redis_sentinel.tasks import EnsuredRedisTask | ||
| @app.task(base=EnsuredRedisTask) | ||
| def add(a, b): | ||
| return a + b |
+1
-1
| [egg_info] | ||
| tag_date = 0 | ||
| tag_build = | ||
| tag_date = 0 | ||
| tag_svn_revision = 0 | ||
+26
-1
@@ -5,2 +5,3 @@ #!/usr/bin/env python | ||
| import os | ||
| from itertools import chain | ||
@@ -17,2 +18,21 @@ from setuptools import find_packages, setup | ||
| def remove_section_from_rst(text, section): | ||
| lines = text.splitlines() | ||
| section_line = lines.index(section) | ||
| separator = lines[section_line + 1] | ||
| assert set(separator) == {separator[0]} | ||
| next_section_line = next( | ||
| i for i, l in enumerate(lines[section_line + 2:]) | ||
| if set(l) == {separator[0]} | ||
| ) | ||
| return '\n'.join(chain( | ||
| lines[:section_line - 1], | ||
| lines[section_line + next_section_line:] | ||
| )) | ||
| authors = read('AUTHORS.rst') | ||
@@ -32,2 +52,7 @@ history = read('HISTORY.rst').replace('.. :changelog:', '') | ||
| long_description = remove_section_from_rst( | ||
| '\n\n'.join([readme, history, authors, licence]), | ||
| 'Master (not yet on PyPI)' | ||
| ) | ||
| setup( | ||
@@ -38,3 +63,3 @@ name='celery-redis-sentinel', | ||
| description='Celery broker and results backend implementation for Redis Sentinel', | ||
| long_description='\n\n'.join([readme, history, authors, licence]), | ||
| long_description=long_description, | ||
| url='https://github.com/dealertrack/celery-redis-sentinel', | ||
@@ -41,0 +66,0 @@ license='MIT', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
67894
6.58%37
8.82%785
6.8%