python-engineio 4.8.0__tar.gz → 4.8.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. {python-engineio-4.8.0/src/python_engineio.egg-info → python-engineio-4.8.2}/PKG-INFO +3 -3
  2. {python-engineio-4.8.0 → python-engineio-4.8.2}/README.md +2 -2
  3. {python-engineio-4.8.0 → python-engineio-4.8.2}/pyproject.toml +1 -1
  4. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_client.py +13 -2
  5. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/asgi.py +6 -1
  6. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/gevent_uwsgi.py +1 -0
  7. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/sanic.py +2 -0
  8. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_server.py +14 -2
  9. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_socket.py +1 -1
  10. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/client.py +4 -1
  11. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/server.py +6 -3
  12. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/socket.py +1 -2
  13. {python-engineio-4.8.0 → python-engineio-4.8.2/src/python_engineio.egg-info}/PKG-INFO +3 -3
  14. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_client.py +2 -2
  15. {python-engineio-4.8.0 → python-engineio-4.8.2}/LICENSE +0 -0
  16. {python-engineio-4.8.0 → python-engineio-4.8.2}/MANIFEST.in +0 -0
  17. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/Makefile +0 -0
  18. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/_static/README.md +0 -0
  19. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/api.rst +0 -0
  20. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/client.rst +0 -0
  21. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/conf.py +0 -0
  22. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/index.rst +0 -0
  23. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/intro.rst +0 -0
  24. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/make.bat +0 -0
  25. {python-engineio-4.8.0 → python-engineio-4.8.2}/docs/server.rst +0 -0
  26. {python-engineio-4.8.0 → python-engineio-4.8.2}/setup.cfg +0 -0
  27. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/__init__.py +0 -0
  28. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/__init__.py +0 -0
  29. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/_websocket_wsgi.py +0 -0
  30. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/aiohttp.py +0 -0
  31. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/eventlet.py +0 -0
  32. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/gevent.py +0 -0
  33. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/threading.py +0 -0
  34. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/async_drivers/tornado.py +0 -0
  35. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/base_client.py +0 -0
  36. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/base_server.py +0 -0
  37. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/base_socket.py +0 -0
  38. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/exceptions.py +0 -0
  39. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/json.py +0 -0
  40. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/middleware.py +0 -0
  41. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/packet.py +0 -0
  42. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/payload.py +0 -0
  43. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/engineio/static_files.py +0 -0
  44. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/python_engineio.egg-info/SOURCES.txt +0 -0
  45. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/python_engineio.egg-info/dependency_links.txt +0 -0
  46. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/python_engineio.egg-info/not-zip-safe +0 -0
  47. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/python_engineio.egg-info/requires.txt +0 -0
  48. {python-engineio-4.8.0 → python-engineio-4.8.2}/src/python_engineio.egg-info/top_level.txt +0 -0
  49. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/__init__.py +0 -0
  50. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/__init__.py +0 -0
  51. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/index.html +0 -0
  52. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_aiohttp.py +0 -0
  53. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_asgi.py +0 -0
  54. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_client.py +0 -0
  55. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_sanic.py +0 -0
  56. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_server.py +0 -0
  57. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_socket.py +0 -0
  58. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/async/test_tornado.py +0 -0
  59. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/__init__.py +0 -0
  60. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/index.html +0 -0
  61. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_async_eventlet.py +0 -0
  62. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_middleware.py +0 -0
  63. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_packet.py +0 -0
  64. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_payload.py +0 -0
  65. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_server.py +0 -0
  66. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/common/test_socket.py +0 -0
  67. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/README.md +0 -0
  68. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/binary_b64_packet.py +0 -0
  69. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/binary_packet.py +0 -0
  70. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/json_packet.py +0 -0
  71. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/payload.py +0 -0
  72. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/run.sh +0 -0
  73. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/server_receive.py +0 -0
  74. {python-engineio-4.8.0 → python-engineio-4.8.2}/tests/performance/text_packet.py +0 -0
  75. {python-engineio-4.8.0 → python-engineio-4.8.2}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-engineio
3
- Version: 4.8.0
3
+ Version: 4.8.2
4
4
  Summary: Engine.IO server and client for Python
5
5
  Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/miguelgrinberg/python-engineio
@@ -27,7 +27,7 @@ python-engineio
27
27
 
28
28
  [![Build status](https://github.com/miguelgrinberg/python-engineio/workflows/build/badge.svg)](https://github.com/miguelgrinberg/python-engineio/actions) [![codecov](https://codecov.io/gh/miguelgrinberg/python-engineio/branch/main/graph/badge.svg)](https://codecov.io/gh/miguelgrinberg/python-engineio)
29
29
 
30
- Python implementation of the `Engine.IO`_ realtime client and server.
30
+ Python implementation of the `Engine.IO` realtime client and server.
31
31
 
32
32
  Sponsors
33
33
  --------
@@ -42,7 +42,7 @@ Many individual sponsors also support this project through small ongoing contrib
42
42
  Resources
43
43
  ---------
44
44
 
45
- - [Documentation](https://python-engineio.readthedocs.io/en/latest/)
45
+ - [Documentation](https://python-engineio.readthedocs.io/)
46
46
  - [PyPI](https://pypi.python.org/pypi/python-engineio)
47
47
  - [Change Log](https://github.com/miguelgrinberg/python-engineio/blob/main/CHANGES.md)
48
48
  - Questions? See the [questions](https://stackoverflow.com/questions/tagged/python-socketio) others have asked on Stack Overflow, or [ask](https://stackoverflow.com/questions/ask?tags=python+python-socketio) your own question.
@@ -3,7 +3,7 @@ python-engineio
3
3
 
4
4
  [![Build status](https://github.com/miguelgrinberg/python-engineio/workflows/build/badge.svg)](https://github.com/miguelgrinberg/python-engineio/actions) [![codecov](https://codecov.io/gh/miguelgrinberg/python-engineio/branch/main/graph/badge.svg)](https://codecov.io/gh/miguelgrinberg/python-engineio)
5
5
 
6
- Python implementation of the `Engine.IO`_ realtime client and server.
6
+ Python implementation of the `Engine.IO` realtime client and server.
7
7
 
8
8
  Sponsors
9
9
  --------
@@ -18,7 +18,7 @@ Many individual sponsors also support this project through small ongoing contrib
18
18
  Resources
19
19
  ---------
20
20
 
21
- - [Documentation](https://python-engineio.readthedocs.io/en/latest/)
21
+ - [Documentation](https://python-engineio.readthedocs.io/)
22
22
  - [PyPI](https://pypi.python.org/pypi/python-engineio)
23
23
  - [Change Log](https://github.com/miguelgrinberg/python-engineio/blob/main/CHANGES.md)
24
24
  - Questions? See the [questions](https://stackoverflow.com/questions/tagged/python-socketio) others have asked on Stack Overflow, or [ask](https://stackoverflow.com/questions/ask?tags=python+python-socketio) your own question.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-engineio"
3
- version = "4.8.0"
3
+ version = "4.8.2"
4
4
  authors = [{name = "Miguel Grinberg", email = "miguel.grinberg@gmail.com"}]
5
5
  description = "Engine.IO server and client for Python"
6
6
  classifiers = [
@@ -15,6 +15,11 @@ from . import payload
15
15
 
16
16
  async_signal_handler_set = False
17
17
 
18
+ # this set is used to keep references to background tasks to prevent them from
19
+ # being garbage collected mid-execution. Solution taken from
20
+ # https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
21
+ task_reference_holder = set()
22
+
18
23
 
19
24
  def async_signal_handler():
20
25
  """SIGINT handler.
@@ -450,8 +455,11 @@ class AsyncClient(base_client.BaseClient):
450
455
  if event in self.handlers:
451
456
  if asyncio.iscoroutinefunction(self.handlers[event]) is True:
452
457
  if run_async:
453
- return self.start_background_task(self.handlers[event],
458
+ task = self.start_background_task(self.handlers[event],
454
459
  *args)
460
+ task_reference_holder.add(task)
461
+ task.add_done_callback(task_reference_holder.discard)
462
+ return task
455
463
  else:
456
464
  try:
457
465
  ret = await self.handlers[event](*args)
@@ -468,7 +476,10 @@ class AsyncClient(base_client.BaseClient):
468
476
  async def async_handler():
469
477
  return self.handlers[event](*args)
470
478
 
471
- return self.start_background_task(async_handler)
479
+ task = self.start_background_task(async_handler)
480
+ task_reference_holder.add(task)
481
+ task.add_done_callback(task_reference_holder.discard)
482
+ return task
472
483
  else:
473
484
  try:
474
485
  ret = self.handlers[event](*args)
@@ -233,9 +233,14 @@ class WebSocket(object): # pragma: no cover
233
233
  self.asgi_send = environ['asgi.send']
234
234
  await self.asgi_send({'type': 'websocket.accept'})
235
235
  await self.handler(self)
236
+ return '' # send nothing as response
236
237
 
237
238
  async def close(self):
238
- pass
239
+ try:
240
+ await self.asgi_send({'type': 'websocket.close'})
241
+ except Exception:
242
+ # if the socket is already close we don't care
243
+ pass
239
244
 
240
245
  async def send(self, message):
241
246
  msg_bytes = None
@@ -61,6 +61,7 @@ class uWSGIWebSocket(object): # pragma: no cover
61
61
 
62
62
  self.app(self)
63
63
  uwsgi.disconnect()
64
+ return '' # send nothing as response
64
65
 
65
66
  def close(self):
66
67
  """Disconnects uWSGI from the client."""
@@ -114,6 +114,7 @@ class WebSocket(object): # pragma: no cover
114
114
  """
115
115
  def __init__(self, handler, server):
116
116
  self.handler = handler
117
+ self.server = server
117
118
  self._sock = None
118
119
 
119
120
  async def __call__(self, environ):
@@ -123,6 +124,7 @@ class WebSocket(object): # pragma: no cover
123
124
 
124
125
  self.environ = environ
125
126
  await self.handler(self)
127
+ return self.server._ok()
126
128
 
127
129
  async def close(self):
128
130
  await self._sock.close()
@@ -6,6 +6,11 @@ from . import exceptions
6
6
  from . import packet
7
7
  from . import async_socket
8
8
 
9
+ # this set is used to keep references to background tasks to prevent them from
10
+ # being garbage collected mid-execution. Solution taken from
11
+ # https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task
12
+ task_reference_holder = set()
13
+
9
14
 
10
15
  class AsyncServer(base_server.BaseServer):
11
16
  """An Engine.IO server for asyncio.
@@ -30,8 +35,11 @@ class AsyncServer(base_server.BaseServer):
30
35
  :param ping_timeout: The time in seconds that the client waits for the
31
36
  server to respond before disconnecting. The default
32
37
  is 20 seconds.
33
- :param max_http_buffer_size: The maximum size of a message. The default
34
- is 1,000,000 bytes.
38
+ :param max_http_buffer_size: The maximum size that is accepted for incoming
39
+ messages. The default is 1,000,000 bytes. In
40
+ spite of its name, the value set in this
41
+ argument is enforced for HTTP long-polling and
42
+ WebSocket connections.
35
43
  :param allow_upgrades: Whether to allow transport upgrades or not.
36
44
  :param http_compression: Whether to compress packages when using the
37
45
  polling transport.
@@ -484,6 +492,8 @@ class AsyncServer(base_server.BaseServer):
484
492
 
485
493
  if run_async:
486
494
  ret = self.start_background_task(run_async_handler)
495
+ task_reference_holder.add(ret)
496
+ ret.add_done_callback(task_reference_holder.discard)
487
497
  else:
488
498
  ret = await run_async_handler()
489
499
  else:
@@ -499,6 +509,8 @@ class AsyncServer(base_server.BaseServer):
499
509
 
500
510
  if run_async:
501
511
  ret = self.start_background_task(run_sync_handler)
512
+ task_reference_holder.add(ret)
513
+ ret.add_done_callback(task_reference_holder.discard)
502
514
  else:
503
515
  ret = await run_sync_handler()
504
516
  return ret
@@ -140,7 +140,7 @@ class AsyncSocket(base_socket.BaseSocket):
140
140
  return self.server._bad_request()
141
141
  ws = self.server._async['websocket'](
142
142
  self._websocket_handler, self.server)
143
- await ws(environ)
143
+ return await ws(environ)
144
144
 
145
145
  async def _websocket_handler(self, ws):
146
146
  """Engine.IO handler for websocket transport."""
@@ -309,7 +309,10 @@ class Client(base_client.BaseClient):
309
309
  self.ssl_verify = False
310
310
 
311
311
  if not self.ssl_verify:
312
- extra_options['sslopt'] = {"cert_reqs": ssl.CERT_NONE}
312
+ if 'sslopt' in extra_options:
313
+ extra_options['sslopt'].update({"cert_reqs": ssl.CERT_NONE})
314
+ else:
315
+ extra_options['sslopt'] = {"cert_reqs": ssl.CERT_NONE}
313
316
 
314
317
  # combine internally generated options with the ones supplied by the
315
318
  # caller. The caller's options take precedence.
@@ -31,8 +31,11 @@ class Server(base_server.BaseServer):
31
31
  :param ping_timeout: The time in seconds that the client waits for the
32
32
  server to respond before disconnecting. The default
33
33
  is 20 seconds.
34
- :param max_http_buffer_size: The maximum size of a message. The default
35
- is 1,000,000 bytes.
34
+ :param max_http_buffer_size: The maximum size that is accepted for incoming
35
+ messages. The default is 1,000,000 bytes. In
36
+ spite of its name, the value set in this
37
+ argument is enforced for HTTP long-polling and
38
+ WebSocket connections.
36
39
  :param allow_upgrades: Whether to allow transport upgrades or not. The
37
40
  default is ``True``.
38
41
  :param http_compression: Whether to compress packages when using the
@@ -306,7 +309,7 @@ class Server(base_server.BaseServer):
306
309
  r = self._method_not_found()
307
310
 
308
311
  if not isinstance(r, dict):
309
- return r or []
312
+ return r
310
313
  if self.http_compression and \
311
314
  len(r['response']) >= self.compression_threshold:
312
315
  encodings = [e.split(';')[0].strip() for e in
@@ -143,8 +143,7 @@ class Socket(base_socket.BaseSocket):
143
143
  return self.server._bad_request()
144
144
  ws = self.server._async['websocket'](
145
145
  self._websocket_handler, self.server)
146
- ws(environ, start_response)
147
- return self.server._ok()
146
+ return ws(environ, start_response)
148
147
 
149
148
  def _websocket_handler(self, ws):
150
149
  """Engine.IO handler for websocket transport."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-engineio
3
- Version: 4.8.0
3
+ Version: 4.8.2
4
4
  Summary: Engine.IO server and client for Python
5
5
  Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/miguelgrinberg/python-engineio
@@ -27,7 +27,7 @@ python-engineio
27
27
 
28
28
  [![Build status](https://github.com/miguelgrinberg/python-engineio/workflows/build/badge.svg)](https://github.com/miguelgrinberg/python-engineio/actions) [![codecov](https://codecov.io/gh/miguelgrinberg/python-engineio/branch/main/graph/badge.svg)](https://codecov.io/gh/miguelgrinberg/python-engineio)
29
29
 
30
- Python implementation of the `Engine.IO`_ realtime client and server.
30
+ Python implementation of the `Engine.IO` realtime client and server.
31
31
 
32
32
  Sponsors
33
33
  --------
@@ -42,7 +42,7 @@ Many individual sponsors also support this project through small ongoing contrib
42
42
  Resources
43
43
  ---------
44
44
 
45
- - [Documentation](https://python-engineio.readthedocs.io/en/latest/)
45
+ - [Documentation](https://python-engineio.readthedocs.io/)
46
46
  - [PyPI](https://pypi.python.org/pypi/python-engineio)
47
47
  - [Change Log](https://github.com/miguelgrinberg/python-engineio/blob/main/CHANGES.md)
48
48
  - Questions? See the [questions](https://stackoverflow.com/questions/tagged/python-socketio) others have asked on Stack Overflow, or [ask](https://stackoverflow.com/questions/ask?tags=python+python-socketio) your own question.
@@ -879,7 +879,7 @@ class TestClient(unittest.TestCase):
879
879
  http.auth = None
880
880
  http.proxies = None
881
881
  http.cert = 'foo.crt'
882
- c = client.Client(http_session=http)
882
+ c = client.Client(http_session=http, ssl_verify=False)
883
883
  c._read_loop_polling = mock.MagicMock()
884
884
  c._read_loop_websocket = mock.MagicMock()
885
885
  c._write_loop = mock.MagicMock()
@@ -889,7 +889,7 @@ class TestClient(unittest.TestCase):
889
889
 
890
890
  assert len(create_connection.call_args_list) == 1
891
891
  assert create_connection.call_args[1] == {
892
- 'sslopt': {'certfile': 'foo.crt'},
892
+ 'sslopt': {'cert_reqs': ssl.CERT_NONE, 'certfile': 'foo.crt'},
893
893
  'header': {},
894
894
  'cookie': '',
895
895
  'enable_multithread': True,
File without changes
File without changes