mirror of
https://github.com/django/daphne.git
synced 2025-07-14 09:52:17 +03:00
Remove dead code
This commit is contained in:
parent
e575693093
commit
5ddeed4a25
|
@ -1,28 +0,0 @@
|
||||||
import functools
|
|
||||||
|
|
||||||
from django.http import HttpRequest, HttpResponse
|
|
||||||
from channels import Channel
|
|
||||||
|
|
||||||
|
|
||||||
def view_producer(channel_name):
|
|
||||||
"""
|
|
||||||
Returns a new view function that actually writes the request to a channel
|
|
||||||
and abandons the response (with an exception the Worker will catch)
|
|
||||||
"""
|
|
||||||
def producing_view(request):
|
|
||||||
Channel(channel_name).send(request.channel_encode())
|
|
||||||
raise HttpResponse.ResponseLater()
|
|
||||||
return producing_view
|
|
||||||
|
|
||||||
|
|
||||||
def view_consumer(func):
|
|
||||||
"""
|
|
||||||
Decorates a normal Django view to be a channel consumer.
|
|
||||||
Does not run any middleware
|
|
||||||
"""
|
|
||||||
@functools.wraps(func)
|
|
||||||
def consumer(message):
|
|
||||||
request = HttpRequest.channel_decode(message.content)
|
|
||||||
response = func(request)
|
|
||||||
message.reply_channel.send(response.channel_encode())
|
|
||||||
return func
|
|
|
@ -42,7 +42,5 @@ class Worker(object):
|
||||||
self.callback(channel, message)
|
self.callback(channel, message)
|
||||||
try:
|
try:
|
||||||
consumer(message)
|
consumer(message)
|
||||||
except Message.Requeue:
|
|
||||||
self.channel_layer.send(channel, content)
|
|
||||||
except:
|
except:
|
||||||
logger.exception("Error processing message with consumer %s:", name_that_thing(consumer))
|
logger.exception("Error processing message with consumer %s:", name_that_thing(consumer))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user