python-engineio 4.9.1__py3-none-any.whl → 4.10.0__py3-none-any.whl

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.
engineio/async_client.py CHANGED
@@ -62,7 +62,7 @@ class AsyncClient(base_client.BaseClient):
62
62
  :param http_session: an initialized ``aiohttp.ClientSession`` object to be
63
63
  used when sending requests to the server. Use it if
64
64
  you need to add special client options such as proxy
65
- servers, SSL certificates, etc.
65
+ servers, SSL certificates, custom CA bundle, etc.
66
66
  :param ssl_verify: ``True`` to verify SSL certificates, or ``False`` to
67
67
  skip SSL certificate verification, allowing
68
68
  connections to servers with self signed certificates.
@@ -63,7 +63,8 @@ class ASGIApp:
63
63
  await self.lifespan(scope, receive, send)
64
64
  elif scope['type'] in ['http', 'websocket'] and (
65
65
  self.engineio_path is None
66
- or scope['path'].startswith(self.engineio_path)):
66
+ or self._ensure_trailing_slash(scope['path']).startswith(
67
+ self.engineio_path)):
67
68
  await self.engineio_server.handle_request(scope, receive, send)
68
69
  else:
69
70
  static_file = get_static_file(scope['path'], self.static_files) \
@@ -127,6 +128,11 @@ class ASGIApp:
127
128
  await send({'type': 'http.response.body',
128
129
  'body': b'Not Found'})
129
130
 
131
+ def _ensure_trailing_slash(self, path):
132
+ if not path.endswith('/'):
133
+ path += '/'
134
+ return path
135
+
130
136
 
131
137
  async def translate_request(scope, receive, send):
132
138
  class AwaitablePayload(object): # pragma: no cover
@@ -25,7 +25,7 @@ class EventletThread: # pragma: no cover
25
25
  return self.g.wait()
26
26
 
27
27
 
28
- class WebSocketWSGI(_WebSocketWSGI):
28
+ class WebSocketWSGI(_WebSocketWSGI): # pragma: no cover
29
29
  def __init__(self, handler, server):
30
30
  try:
31
31
  super().__init__(
engineio/async_server.py CHANGED
@@ -70,6 +70,10 @@ class AsyncServer(base_server.BaseServer):
70
70
  :param async_handlers: If set to ``True``, run message event handlers in
71
71
  non-blocking threads. To run handlers synchronously,
72
72
  set to ``False``. The default is ``True``.
73
+ :param monitor_clients: If set to ``True``, a background task will ensure
74
+ inactive clients are closed. Set to ``False`` to
75
+ disable the monitoring task (not recommended). The
76
+ default is ``True``.
73
77
  :param transports: The list of allowed transports. Valid transports
74
78
  are ``'polling'`` and ``'websocket'``. Defaults to
75
79
  ``['polling', 'websocket']``.
@@ -284,18 +288,24 @@ class AsyncServer(base_server.BaseServer):
284
288
  r = self._bad_request('Invalid session ' + sid)
285
289
  else:
286
290
  socket = self._get_socket(sid)
287
- try:
288
- packets = await socket.handle_get_request(environ)
289
- if isinstance(packets, list):
290
- r = self._ok(packets, jsonp_index=jsonp_index)
291
- else:
292
- r = packets
293
- except exceptions.EngineIOError:
294
- if sid in self.sockets: # pragma: no cover
295
- await self.disconnect(sid)
296
- r = self._bad_request()
297
- if sid in self.sockets and self.sockets[sid].closed:
298
- del self.sockets[sid]
291
+ if self.transport(sid) != transport:
292
+ self._log_error_once(
293
+ 'Invalid transport for session ' + sid,
294
+ 'bad-transport')
295
+ r = self._bad_request('Invalid transport')
296
+ else:
297
+ try:
298
+ packets = await socket.handle_get_request(environ)
299
+ if isinstance(packets, list):
300
+ r = self._ok(packets, jsonp_index=jsonp_index)
301
+ else:
302
+ r = packets
303
+ except exceptions.EngineIOError:
304
+ if sid in self.sockets: # pragma: no cover
305
+ await self.disconnect(sid)
306
+ r = self._bad_request()
307
+ if sid in self.sockets and self.sockets[sid].closed:
308
+ del self.sockets[sid]
299
309
  elif method == 'POST':
300
310
  if sid is None or sid not in self.sockets:
301
311
  self._log_error_once('Invalid session ' + sid, 'bad-sid')
engineio/client.py CHANGED
@@ -510,8 +510,7 @@ class Client(base_client.BaseClient):
510
510
  except Exception as e: # pragma: no cover
511
511
  if type(e) is OSError and e.errno == 9:
512
512
  self.logger.info(
513
- 'WebSocket connection is closing, aborting',
514
- str(e))
513
+ 'WebSocket connection is closing, aborting')
515
514
  else:
516
515
  self.logger.info(
517
516
  'Unexpected error receiving packet: "%s", aborting',
engineio/server.py CHANGED
@@ -180,7 +180,7 @@ class Server(base_server.BaseServer):
180
180
  if sid in self.sockets: # pragma: no cover
181
181
  del self.sockets[sid]
182
182
  else:
183
- for client in self.sockets.values():
183
+ for client in self.sockets.copy().values():
184
184
  client.close()
185
185
  self.sockets = {}
186
186
 
@@ -270,19 +270,25 @@ class Server(base_server.BaseServer):
270
270
  r = self._bad_request('Invalid session')
271
271
  else:
272
272
  socket = self._get_socket(sid)
273
- try:
274
- packets = socket.handle_get_request(
275
- environ, start_response)
276
- if isinstance(packets, list):
277
- r = self._ok(packets, jsonp_index=jsonp_index)
278
- else:
279
- r = packets
280
- except exceptions.EngineIOError:
281
- if sid in self.sockets: # pragma: no cover
282
- self.disconnect(sid)
283
- r = self._bad_request()
284
- if sid in self.sockets and self.sockets[sid].closed:
285
- del self.sockets[sid]
273
+ if self.transport(sid) != transport:
274
+ self._log_error_once(
275
+ 'Invalid transport for session ' + sid,
276
+ 'bad-transport')
277
+ r = self._bad_request('Invalid transport')
278
+ else:
279
+ try:
280
+ packets = socket.handle_get_request(
281
+ environ, start_response)
282
+ if isinstance(packets, list):
283
+ r = self._ok(packets, jsonp_index=jsonp_index)
284
+ else:
285
+ r = packets
286
+ except exceptions.EngineIOError:
287
+ if sid in self.sockets: # pragma: no cover
288
+ self.disconnect(sid)
289
+ r = self._bad_request()
290
+ if sid in self.sockets and self.sockets[sid].closed:
291
+ del self.sockets[sid]
286
292
  elif method == 'POST':
287
293
  if sid is None or sid not in self.sockets:
288
294
  self._log_error_once(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-engineio
3
- Version: 4.9.1
3
+ Version: 4.10.0
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
@@ -1,31 +1,31 @@
1
1
  engineio/__init__.py,sha256=0R2PY1EXu3sicP7mkA0_QxEVGRlFlgvsxfhByqREE1A,481
2
- engineio/async_client.py,sha256=QyHBWpLZxfBc4lK_eodkPM0xzsfVYpt7mzNaA9uG3cg,27932
3
- engineio/async_server.py,sha256=dOhDfyPY817RMzEFq9U-IH8e0b7NCEFKTi-c8zb-UCw,25098
2
+ engineio/async_client.py,sha256=jC7T6r_ya9LV46q4OdIQ041-3uLlRr6aUt__YmHNPEM,27950
3
+ engineio/async_server.py,sha256=q29JCvIpCriUXZoqHwjJUwV2bK2MRypMQptROGw6imI,25738
4
4
  engineio/async_socket.py,sha256=P8OZW1N5y7jr2hW1qLLK2y_Clt7aHdv2ucYW69mbU4Q,10305
5
5
  engineio/base_client.py,sha256=Q_w0Stvy89wPHwWk7411dRxpGjxNPypm4xy_4XMPZ9M,4872
6
6
  engineio/base_server.py,sha256=Em2RRpbohulKjmYTWHnf_lALKvTT_jHr442Rr2g_BEQ,14013
7
7
  engineio/base_socket.py,sha256=Bw6TWv1pnlXcDdqT59C5CyTaBi7l-_mkykIUuZLjz-g,400
8
- engineio/client.py,sha256=79mpLSZT1m-rSu0EcfvOR6TtJbJ6ncCsO0nF7l7WW9A,26317
8
+ engineio/client.py,sha256=m_eLSes3b-mE5MYajELquSktkAWceCNGZOtUU78as50,26285
9
9
  engineio/exceptions.py,sha256=FyuMb5qhX9CUYP3fEoe1m-faU96ApdQTSbblaaoo8LA,292
10
10
  engineio/json.py,sha256=SG5FTojqd1ix6u0dKXJsZVqqdYioZLO4S2GPL7BKl3U,405
11
11
  engineio/middleware.py,sha256=BF_qHAIZZnIbfiP256SD1CX3kzNWbSuto1cpih8oIFg,3766
12
12
  engineio/packet.py,sha256=ETMeLgdpZghXK9fth93IZO8pIft6Sg3d1QGpyTx4xBE,3189
13
13
  engineio/payload.py,sha256=2iLIFgIweTWkLok_UZ5zCgELmRSGyUUI5eeYcEerFSs,1547
14
- engineio/server.py,sha256=UegXydKobZaR1O0MxS_MENKNF7PBjpP_kPI0-OpI5EQ,21558
14
+ engineio/server.py,sha256=v0QnoLCD1ReVAhzQRn5keHmjZ61jEJXNQeikfXaELl0,21926
15
15
  engineio/socket.py,sha256=dasec3jXoV2eR1jmIrhEIfHzyUuuv8FwvxLB3DpyjeY,9996
16
16
  engineio/static_files.py,sha256=pwez9LQFaSQXMbtI0vLyD6UDiokQ4rNfmRYgVLKOthc,2064
17
17
  engineio/async_drivers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  engineio/async_drivers/_websocket_wsgi.py,sha256=FGoRBGOUsEtlfklYNylR0o3oLOGmXIR8QzaCsGLgr3I,949
19
19
  engineio/async_drivers/aiohttp.py,sha256=zJdujjO6dSL_oKDDr4xfO4ID_Vd8faEp1AOIW4ogKME,3768
20
- engineio/async_drivers/asgi.py,sha256=CZ_XOiI83vXm_p6_6VqaxocwvgVAUhphtAsZaIyI3_E,10837
21
- engineio/async_drivers/eventlet.py,sha256=IG6oLaWH663dw5CEnO-SRz6IsJb6lO55kRCYTdmqZE0,1755
20
+ engineio/async_drivers/asgi.py,sha256=mvCErNpYw1T7XE_1Ixb0YQN0YqJkKMpWqNV5_tZQYMg,11011
21
+ engineio/async_drivers/eventlet.py,sha256=_ZgPg0HTx_yhSm5iBcd3ez01yMg3KRFmb2ycKD8o8pY,1775
22
22
  engineio/async_drivers/gevent.py,sha256=hnJHeWdDQE2jfoLCP5DnwVPzsQlcTLJUMA5EVf1UL-k,2962
23
23
  engineio/async_drivers/gevent_uwsgi.py,sha256=cnjCsnDHTa6rKgwDKD6rLvIw1Yun-g4c1QbujOC_bMY,5962
24
24
  engineio/async_drivers/sanic.py,sha256=SY0HIp5DUHF7B55tJCBB_8qDjrRTD_FyNQ2cIwRIGR8,4538
25
25
  engineio/async_drivers/threading.py,sha256=ywmG59d4H6OHZjKarBN97-9BHEsRxFEz9YN-E9QAu_I,463
26
26
  engineio/async_drivers/tornado.py,sha256=9bB7FvY47Snx_h4rsNwRk5wIINf2ju7hXWTAqF3intA,5909
27
- python_engineio-4.9.1.dist-info/LICENSE,sha256=yel9Pbwfu82094CLKCzWRtuIev9PUxP-a76NTDFAWpw,1082
28
- python_engineio-4.9.1.dist-info/METADATA,sha256=MNHZzYM4BsSNebhsXVslP-kaHg08S74pkLABnPxDRYw,2244
29
- python_engineio-4.9.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
30
- python_engineio-4.9.1.dist-info/top_level.txt,sha256=u8PmNisCZLwRYcWrNLe9wutQ2tt4zNi8IH362c-HWuA,9
31
- python_engineio-4.9.1.dist-info/RECORD,,
27
+ python_engineio-4.10.0.dist-info/LICENSE,sha256=yel9Pbwfu82094CLKCzWRtuIev9PUxP-a76NTDFAWpw,1082
28
+ python_engineio-4.10.0.dist-info/METADATA,sha256=SaBVFlF_cqRa2i_sQ3Fdiaz6GdxT1qASxZpSugLD57A,2245
29
+ python_engineio-4.10.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
30
+ python_engineio-4.10.0.dist-info/top_level.txt,sha256=u8PmNisCZLwRYcWrNLe9wutQ2tt4zNi8IH362c-HWuA,9
31
+ python_engineio-4.10.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5