Move ResponseLater into exceptions module

This commit is contained in:
Andrew Godwin 2016-02-24 00:39:48 +00:00
parent 5ff77719be
commit 38c6df8125
2 changed files with 19 additions and 7 deletions

16
channels/exceptions.py Normal file
View File

@ -0,0 +1,16 @@
class ConsumeLater(Exception):
"""
Exception that says that the current message should be re-queued back
onto its channel as it's not ready to be consumd yet (e.g. global order
is being enforced)
"""
pass
class ResponseLater(Exception):
"""
Exception raised inside a Django view when the view has passed
responsibility for the response to another consumer, and so is not
returning a response.
"""
pass

View File

@ -14,6 +14,8 @@ from django.core.urlresolvers import set_script_prefix
from django.utils import six
from django.utils.functional import cached_property
from .exceptions import ResponseLater as ResponseLaterOuter
logger = logging.getLogger('django.request')
@ -23,13 +25,7 @@ class AsgiRequest(http.HttpRequest):
dict, and wraps request body handling.
"""
class ResponseLater(Exception):
"""
Exception that will cause any handler to skip around response
transmission and presume something else will do it later.
"""
def __init__(self):
Exception.__init__(self, "Response later")
ResponseLater = ResponseLaterOuter
def __init__(self, message):
self.message = message