Releasing version 1.2.0

Includes some test fixes for the new reply channel style.
This commit is contained in:
Andrew Godwin 2017-04-01 15:18:43 +01:00
parent cddb0aa89e
commit 46656aad24
9 changed files with 33 additions and 11 deletions

View File

@ -1,3 +1,23 @@
1.2.0 (2017-04-01)
------------------
* The new process-specific channel support is now implemented, resulting in
significantly less traffic to your channel backend.
* Native twisted blocking support for channel layers that support it is now
used. While it is a lot more efficient, it is also sometimes slightly more
latent; you can disable it using --force-sync.
* Native SSL termination is now correctly reflected in the ASGI-HTTP `scheme`
key.
* accept: False is now a valid way to deny a connection, as well as close: True.
* HTTP version is now correctly sent as one of "1.0", "1.1" or "2".
* More command line options for websocket timeouts
1.1.0 (2017-03-18) 1.1.0 (2017-03-18)
------------------ ------------------

View File

@ -1 +1 @@
__version__ = "1.1.0" __version__ = "1.2.0"

View File

@ -61,6 +61,7 @@ class WebRequest(http.Request):
self._got_response_start = False self._got_response_start = False
except Exception: except Exception:
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
raise
def process(self): def process(self):
try: try:
@ -310,6 +311,7 @@ class HTTPFactory(http.HTTPFactory):
self.channel_layer = channel_layer self.channel_layer = channel_layer
self.action_logger = action_logger self.action_logger = action_logger
self.send_channel = send_channel self.send_channel = send_channel
assert self.send_channel is not None
self.timeout = timeout self.timeout = timeout
self.websocket_timeout = websocket_timeout self.websocket_timeout = websocket_timeout
self.websocket_connect_timeout = websocket_connect_timeout self.websocket_connect_timeout = websocket_connect_timeout

View File

@ -99,7 +99,7 @@ def _run_through_daphne(request, channel_name):
but it works for now. but it works for now.
""" """
channel_layer = ChannelLayer() channel_layer = ChannelLayer()
factory = HTTPFactory(channel_layer) factory = HTTPFactory(channel_layer, send_channel="test!")
proto = factory.buildProtocol(('127.0.0.1', 0)) proto = factory.buildProtocol(('127.0.0.1', 0))
transport = proto_helpers.StringTransport() transport = proto_helpers.StringTransport()
proto.makeConnection(transport) proto.makeConnection(transport)

View File

@ -152,7 +152,7 @@ class TestProxyHandling(unittest.TestCase):
def setUp(self): def setUp(self):
self.channel_layer = ChannelLayer() self.channel_layer = ChannelLayer()
self.factory = HTTPFactory(self.channel_layer) self.factory = HTTPFactory(self.channel_layer, send_channel="test!")
self.proto = self.factory.buildProtocol(('127.0.0.1', 0)) self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
self.tr = proto_helpers.StringTransport() self.tr = proto_helpers.StringTransport()
self.proto.makeConnection(self.tr) self.proto.makeConnection(self.tr)

View File

@ -94,7 +94,7 @@ class TestHTTPResponse(TestCase):
def setUp(self): def setUp(self):
self.channel_layer = ChannelLayer() self.channel_layer = ChannelLayer()
self.factory = HTTPFactory(self.channel_layer) self.factory = HTTPFactory(self.channel_layer, send_channel="test!")
self.proto = self.factory.buildProtocol(('127.0.0.1', 0)) self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
self.tr = proto_helpers.StringTransport() self.tr = proto_helpers.StringTransport()
self.proto.makeConnection(self.tr) self.proto.makeConnection(self.tr)

View File

@ -14,7 +14,7 @@ class TestWebSocketProtocol(TestCase):
def setUp(self): def setUp(self):
self.channel_layer = ChannelLayer() self.channel_layer = ChannelLayer()
self.factory = HTTPFactory(self.channel_layer) self.factory = HTTPFactory(self.channel_layer, send_channel="test!")
self.proto = self.factory.buildProtocol(('127.0.0.1', 0)) self.proto = self.factory.buildProtocol(('127.0.0.1', 0))
self.tr = proto_helpers.StringTransport() self.tr = proto_helpers.StringTransport()
self.proto.makeConnection(self.tr) self.proto.makeConnection(self.tr)
@ -46,7 +46,7 @@ class TestWebSocketProtocol(TestCase):
(b'sec-websocket-version', b'13'), (b'sec-websocket-version', b'13'),
(b'upgrade', b'websocket')] (b'upgrade', b'websocket')]
) )
self.assertTrue(message['reply_channel'].startswith("websocket.send!")) self.assertTrue(message['reply_channel'].startswith("test!"))
# Accept the connection # Accept the connection
self.factory.dispatch_reply( self.factory.dispatch_reply(
@ -107,7 +107,7 @@ class TestWebSocketProtocol(TestCase):
# Get the resulting message off of the channel layer # Get the resulting message off of the channel layer
_, message = self.channel_layer.receive(["websocket.connect"]) _, message = self.channel_layer.receive(["websocket.connect"])
self.assertIn((b'origin', b'file://'), message['headers']) self.assertIn((b'origin', b'file://'), message['headers'])
self.assertTrue(message['reply_channel'].startswith("websocket.send!")) self.assertTrue(message['reply_channel'].startswith("test!"))
# Accept the connection # Accept the connection
self.factory.dispatch_reply( self.factory.dispatch_reply(
@ -136,7 +136,7 @@ class TestWebSocketProtocol(TestCase):
# Get the resulting message off of the channel layer # Get the resulting message off of the channel layer
_, message = self.channel_layer.receive(["websocket.connect"]) _, message = self.channel_layer.receive(["websocket.connect"])
self.assertNotIn(b'origin', [header_tuple[0] for header_tuple in message['headers']]) self.assertNotIn(b'origin', [header_tuple[0] for header_tuple in message['headers']])
self.assertTrue(message['reply_channel'].startswith("websocket.send!")) self.assertTrue(message['reply_channel'].startswith("test!"))
# Accept the connection # Accept the connection
self.factory.dispatch_reply( self.factory.dispatch_reply(

View File

@ -50,7 +50,7 @@ class ASGITestCase(unittest.TestCase):
# == Assertions about required channel_message fields == # == Assertions about required channel_message fields ==
reply_channel = channel_message['reply_channel'] reply_channel = channel_message['reply_channel']
self.assertIsInstance(reply_channel, six.text_type) self.assertIsInstance(reply_channel, six.text_type)
self.assertTrue(reply_channel.startswith('http.response!')) self.assertTrue(reply_channel.startswith('test!'))
http_version = channel_message['http_version'] http_version = channel_message['http_version']
self.assertIsInstance(http_version, six.text_type) self.assertIsInstance(http_version, six.text_type)

View File

@ -23,9 +23,9 @@ setup(
packages=find_packages() + ['twisted.plugins'], packages=find_packages() + ['twisted.plugins'],
include_package_data=True, include_package_data=True,
install_requires=[ install_requires=[
'asgiref>=1.0.0', 'asgiref~=1.1',
'twisted>=17.1', 'twisted>=17.1',
'autobahn>=0.12', 'autobahn>=0.18',
], ],
extras_require={ extras_require={
'tests': ['hypothesis', 'tox'] 'tests': ['hypothesis', 'tox']