0001-Adjust-ws4py-for-Python-3.7-syntax.patch 1.9 KB

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