Skip to content

Commit

Permalink
Merge pull request #149 from iheartradio/make-tox-pass
Browse files Browse the repository at this point in the history
Make Tox Pass
  • Loading branch information
BWStearns committed Mar 14, 2018
2 parents e08cf0a + 09b074a commit e5ced10
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions henson/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def error(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'error')
return callback
Expand All @@ -102,6 +103,7 @@ def message_acknowledgement(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'message_acknowledgement')
return callback
Expand All @@ -121,6 +123,7 @@ def message_preprocessor(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'message_preprocessor')
return callback
Expand All @@ -140,6 +143,7 @@ def result_postprocessor(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'result_postprocessor')
return callback
Expand Down Expand Up @@ -167,6 +171,7 @@ def run_forever(self, num_workers=1, loop=None, debug=False):
Unhandled exceptions resulting from processing a message
while the consumer is still active will stop cause the
application to shut down gracefully.
"""
if self.consumer is None:
raise TypeError("The Application's consumer cannot be None.")
Expand Down Expand Up @@ -272,6 +277,7 @@ def startup(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'startup')
return callback
Expand All @@ -290,6 +296,7 @@ def teardown(self, callback):
Raises:
TypeError: If the callback isn't a coroutine.
"""
self._register_callback(callback, 'teardown')
return callback
Expand Down Expand Up @@ -324,6 +331,7 @@ def _apply_callbacks(self, callbacks, value):
Returns:
The return value of the final callback.
"""
for callback in callbacks:
value = yield from callback(self, value)
Expand Down Expand Up @@ -452,6 +460,7 @@ def _register_callback(self, callback, callback_container):
Raises:
TypeError: If the callback isn't a coroutine.
"""
if not asyncio.iscoroutinefunction(callback):
raise TypeError('The callback must be a coroutine.')
Expand Down Expand Up @@ -482,6 +491,7 @@ def _new_event_loop():
Returns:
asyncio.AbstractEventLoopPolicy: The new event loop.
"""
try:
import uvloop
Expand Down
1 change: 1 addition & 0 deletions henson/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def _import_application(application_path):
Returns:
Tuple[str, henson.base.Application]: A two-tuple containing the
import path and the imported application.
"""
# Add the present working directory to the import path so that
# services can be found without installing them to site-packages
Expand Down
6 changes: 6 additions & 0 deletions henson/contrib/retry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def _calculate_delay(delay, backoff, number_of_retries):
Returns:
numbers.Number: The amount of time to wait.
"""
backoff_factor = backoff ** number_of_retries
return delay * backoff_factor
Expand All @@ -43,6 +44,7 @@ def _exceeded_threshold(number_of_retries, maximum_retries):
Returns:
bool: True if the maximum number of retry attempts have already
been made.
"""
if maximum_retries is None:
# Retry forever.
Expand All @@ -60,6 +62,7 @@ def _exceeded_timeout(start_time, duration):
Returns:
bool: True if the timeout has passed.
"""
if duration is None:
# Retry forever.
Expand All @@ -85,6 +88,7 @@ def _retry(app, message, exc):
Raises:
Abort: If the message is scheduled to be retried.
"""
if not isinstance(exc, app.settings['RETRY_EXCEPTIONS']):
# If the exception raised isn't retryable, return control so the
Expand Down Expand Up @@ -135,6 +139,7 @@ def _retry_info(message):
Returns:
dict: The retry attempt information.
"""
info = message.get('_retry', {})
info.setdefault('count', 0)
Expand Down Expand Up @@ -171,6 +176,7 @@ def init_app(self, app):
Raises:
TypeError: If the callback isn't a coroutine.
ValueError: If the delay or backoff is negative.
"""
super().init_app(app)

Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ envlist = docs,pep8,py34,py35,py36
[testenv]
deps =
coverage
pytest
pytest<3.3
pytest-asyncio<0.4.0
pytest-capturelog
sphinx==1.7.0
sphinxcontrib-autoprogram
commands =
python -m coverage run -m pytest --strict {posargs: tests}
Expand Down

0 comments on commit e5ced10

Please sign in to comment.