From 00984a0a8e7ba8d511d32462da3d5058ec653ff7 Mon Sep 17 00:00:00 2001 From: Maik Hoepfel Date: Mon, 30 Jan 2017 15:54:45 +0100 Subject: [PATCH] Require asgiref 1.0 and use receive instead of receive_many As both daphne and asgiref had a 1.0 release, I think it makes sense to require the presumably more stable asgiref 1.0. It's also a good occasion to fix the deprecation warnings when running the tests by switching to receive instead of receive_many. --- daphne/server.py | 4 ++-- daphne/tests/test_http.py | 14 +++++++------- daphne/tests/test_ws.py | 2 +- setup.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/daphne/server.py b/daphne/server.py index 4f79fd2..7b05a55 100755 --- a/daphne/server.py +++ b/daphne/server.py @@ -115,7 +115,7 @@ class Server(object): if channels: delay = 0.01 try: - channel, message = self.channel_layer.receive_many(channels, block=False) + channel, message = self.channel_layer.receive(channels, block=False) except Exception as e: logger.error('Error at trying to receive messages: %s' % e) delay = 5.00 @@ -142,7 +142,7 @@ class Server(object): channels = self.factory.reply_channels() if channels: try: - channel, message = yield self.channel_layer.receive_many_twisted(channels) + channel, message = yield self.channel_layer.receive_twisted(channels) except Exception as e: logger.error('Error at trying to receive messages: %s' % e) yield self.sleep(5.00) diff --git a/daphne/tests/test_http.py b/daphne/tests/test_http.py index de9bef3..c9f5c7b 100644 --- a/daphne/tests/test_http.py +++ b/daphne/tests/test_http.py @@ -30,7 +30,7 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) self.assertEqual(message['http_version'], "1.1") self.assertEqual(message['method'], "GET") self.assertEqual(message['scheme'], "http") @@ -64,7 +64,7 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer, check root_path - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) self.assertEqual(message['root_path'], "/foobar /bar") def test_http_disconnect_sets_path_key(self): @@ -78,7 +78,7 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the request message - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) # Send back an example response self.factory.dispatch_reply( @@ -91,7 +91,7 @@ class TestHTTPProtocol(TestCase): ) # Get the disconnection notification - _, disconnect_message = self.channel_layer.receive_many(["http.disconnect"]) + _, disconnect_message = self.channel_layer.receive(["http.disconnect"]) self.assertEqual(disconnect_message['path'], "/te st-à/") def test_x_forwarded_for_ignored(self): @@ -106,7 +106,7 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) self.assertEqual(message['client'], ['192.168.1.1', 54321]) def test_x_forwarded_for_parsed(self): @@ -123,7 +123,7 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) self.assertEqual(message['client'], ['10.1.2.3', 80]) def test_x_forwarded_for_port_missing(self): @@ -139,5 +139,5 @@ class TestHTTPProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer - _, message = self.channel_layer.receive_many(["http.request"]) + _, message = self.channel_layer.receive(["http.request"]) self.assertEqual(message['client'], ['10.1.2.3', 0]) diff --git a/daphne/tests/test_ws.py b/daphne/tests/test_ws.py index 5fc398d..54e1169 100644 --- a/daphne/tests/test_ws.py +++ b/daphne/tests/test_ws.py @@ -33,7 +33,7 @@ class TestWebSocketProtocol(TestCase): b"\r\n" ) # Get the resulting message off of the channel layer - _, message = self.channel_layer.receive_many(["websocket.connect"]) + _, message = self.channel_layer.receive(["websocket.connect"]) self.assertEqual(message['path'], "/chat") self.assertEqual(message['query_string'], "") self.assertEqual( diff --git a/setup.py b/setup.py index d0e0a92..e5bf8a6 100755 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( packages=find_packages() + ['twisted.plugins'], include_package_data=True, install_requires=[ - 'asgiref>=0.13', + 'asgiref>=1.0.0', 'twisted>=16.0', 'autobahn>=0.12', ],