1From dfe6f65b7078315c32cebb727e9c47ead7603475 Mon Sep 17 00:00:00 2001
2From: Asaf Kahlon <asafka7@gmail.com>
3Date: Sun, 13 Oct 2019 16:44:44 +0300
4Subject: [PATCH 1/1] Adjust ws4py for Python 3.7 syntax
5
6Since Python 3.7, "async" has become a keyword and cannot be used.
7Thus, instead of asyncio.async we will use asyncio.ensure_future.
8
9There's also a pull request with this change:
10https://github.com/Lawouach/WebSocket-for-Python/pull/245
11
12Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
13---
14 ws4py/async_websocket.py    | 4 ++--
15 ws4py/server/tulipserver.py | 2 +-
16 2 files changed, 3 insertions(+), 3 deletions(-)
17
18diff --git a/ws4py/async_websocket.py b/ws4py/async_websocket.py
19index 9e2a4c7..ea296b4 100644
20--- a/ws4py/async_websocket.py
21+++ b/ws4py/async_websocket.py
22@@ -84,7 +84,7 @@ class WebSocket(_WebSocket):
23         def closeit():
24             yield from self.proto.writer.drain()
25             self.proto.writer.close()
26-        asyncio.async(closeit())
27+        asyncio.ensure_future(closeit())
28
29     def _write(self, data):
30         """
31@@ -94,7 +94,7 @@ class WebSocket(_WebSocket):
32         def sendit(data):
33             self.proto.writer.write(data)
34             yield from self.proto.writer.drain()
35-        asyncio.async(sendit(data))
36+        asyncio.ensure_future(sendit(data))
37
38     @asyncio.coroutine
39     def run(self):
40diff --git a/ws4py/server/tulipserver.py b/ws4py/server/tulipserver.py
41index 2786c16..85312a2 100644
42--- a/ws4py/server/tulipserver.py
43+++ b/ws4py/server/tulipserver.py
44@@ -40,7 +40,7 @@ class WebSocketProtocol(asyncio.StreamReaderProtocol):
45         #self.stream.set_transport(transport)
46         asyncio.StreamReaderProtocol.connection_made(self, transport)
47         # Let make it concurrent for others to tag along
48-        f = asyncio.async(self.handle_initial_handshake())
49+        f = asyncio.ensure_future(self.handle_initial_handshake())
50         f.add_done_callback(self.terminated)
51
52     @property
53--
542.20.1
55
56