vuer 0.0.18__py3-none-any.whl → 0.0.19__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.

Potentially problematic release.


This version of vuer might be problematic. Click here for more details.

Binary file
vuer/server.py CHANGED
@@ -2,10 +2,12 @@ import asyncio
2
2
  from asyncio import sleep
3
3
  from collections import deque, defaultdict
4
4
  from functools import partial
5
- from typing import cast, Callable, Coroutine
5
+ from typing import cast, Callable, Coroutine, Dict
6
6
  from uuid import uuid4
7
7
 
8
+ from aiohttp.web_request import Request
8
9
  from aiohttp.web_response import Response
10
+ from aiohttp.web_ws import WebSocketResponse
9
11
  from msgpack import packb, unpackb
10
12
  from params_proto import Proto, PrefixProto
11
13
  from websockets import ConnectionClosedError
@@ -55,6 +57,24 @@ class VuerSession:
55
57
  self.downlink_queue = que_maker()
56
58
  self.uplink_queue = que_maker()
57
59
 
60
+ @property
61
+ def socket(self):
62
+ """Getter for the websocket object.
63
+
64
+ this is useful for closing the socket session from the client side.
65
+
66
+ Example Usage::
67
+
68
+ @app.spawn(start=True):
69
+ async def main(session: VuerSession):
70
+ print("doing something...")
71
+ await sleep(1.0)
72
+
73
+ print("I am done! closing the socket.")
74
+ session.socket.close()
75
+ """
76
+ return self.vuer.ws[self.CURRENT_WS_ID]
77
+
58
78
  def __matmul__(self, event: ServerEvent):
59
79
  """
60
80
  Send a ServerEvent to the client.
@@ -294,7 +314,7 @@ class Vuer(PrefixProto, Server):
294
314
  # todo: can remove
295
315
  self.page = Page()
296
316
 
297
- self.ws = {}
317
+ self.ws: Dict[str, WebSocketResponse] = {}
298
318
  self.socket_handler: SocketHandler = None
299
319
  self.spawned_coroutines = []
300
320
 
@@ -510,7 +530,7 @@ class Vuer(PrefixProto, Server):
510
530
  else:
511
531
  await sleep(0.0)
512
532
 
513
- async def downlink(self, request, ws):
533
+ async def downlink(self, request: Request, ws: WebSocketResponse):
514
534
  """
515
535
  The websocket handler for receiving messages from the client.
516
536
 
@@ -530,7 +550,17 @@ class Vuer(PrefixProto, Server):
530
550
  self._add_task(self.uplink(vuer_proxy))
531
551
 
532
552
  if self.socket_handler is not None:
533
- task = self._add_task(self.socket_handler(vuer_proxy))
553
+
554
+ async def handler():
555
+ try:
556
+ await self.socket_handler(vuer_proxy)
557
+ except Exception:
558
+ await self.close_ws(ws_id)
559
+ return
560
+
561
+ await self.close_ws(ws_id)
562
+
563
+ task = self._add_task(handler())
534
564
 
535
565
  if hasattr(generator, "__anext__"):
536
566
  serverEvent = await generator.__anext__()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vuer
3
- Version: 0.0.18
3
+ Version: 0.0.19
4
4
  Home-page: https://github.com/geyang/vuer
5
5
  Author: Ge Yang<ge.ike.yang@gmail.com>
6
6
  Author-email: ge.ike.yang@gmail.com
@@ -3,14 +3,14 @@ vuer/base.py,sha256=R-PtD39ouihiEGmSfJL26chlU0XkFJP-JmBNYzDdEvM,3068
3
3
  vuer/events.py,sha256=8AAzkfbm5jHkeMh17Z57n8YTxF4mheWC3Qbya4XkQSc,7291
4
4
  vuer/schemas.py,sha256=aZOocE02gO43SLLfeYSxxac0x38TmyTcfs_iFh5hsJ4,18152
5
5
  vuer/serdes.py,sha256=gD2iA9Yypu1QjocneOT3Nc0y6q_mdHn9zW1ko5j3I7c,2600
6
- vuer/server.py,sha256=OsXSq6iScFTG-yvAXWAik-EwNwEKdd1F84nUqBwyrjE,19955
6
+ vuer/server.py,sha256=gIYbWwc-25JwtK9eeojQJtPSRMrCZ8rRcmZToDMnrpg,20851
7
7
  vuer/types.py,sha256=N2KLa0fl6z8Jm6cJwZoD8Vqrins_AayG5BCGk1p3Eek,1279
8
8
  vuer/__pycache__/__init__.cpython-38.pyc,sha256=rS-9zzAjFEXnObk5q3E5Rex_uvoJ-Ccfz7Hs9DGNVgs,188
9
9
  vuer/__pycache__/base.cpython-38.pyc,sha256=Z5EFlRX9RqZsQUszvqPtAhLv_5QG5wlUXW7JbFd_XDc,3824
10
10
  vuer/__pycache__/events.cpython-38.pyc,sha256=zx3bXeJixqOyCFe2nA7qpq6jiCJ49kRaXO-xONGUyeQ,9616
11
11
  vuer/__pycache__/schemas.cpython-38.pyc,sha256=hvY9Aak8zE-zKcWiwuNe6DghOw9qH_zSe_FtkBOAPPk,23234
12
12
  vuer/__pycache__/serdes.cpython-38.pyc,sha256=KMxTjPEWuSGn2bqBAl5OLIDSCSoqfPDGfk3fvNnRDYA,2253
13
- vuer/__pycache__/server.cpython-38.pyc,sha256=kAsC8t-JgTOOccZMaXZMEqgTSV3C3T5Oyj1sl-QABM4,18696
13
+ vuer/__pycache__/server.cpython-38.pyc,sha256=z44pZ0u3x6ZLwDOh2skBFlvNEnGO2re4cdhRAippzy0,19636
14
14
  vuer/__pycache__/types.cpython-38.pyc,sha256=IhlXtkT-XWM0V1420FDuoqIYnpvRvekYVkGqEK7fAV8,1819
15
15
  vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -29,9 +29,9 @@ vuer/schemas/__pycache__/__init__.cpython-38.pyc,sha256=NRnVrpIDBKne93xOUY1-Wpav
29
29
  vuer/schemas/__pycache__/drei_components.cpython-38.pyc,sha256=g_ufcKxf-XKfZLdUV-HqKnjIrgxGWFv51aHLWQgH-ws,7712
30
30
  vuer/schemas/__pycache__/html_components.cpython-38.pyc,sha256=q0DMFwNkYbnaH1A8w3BowMiQAlmGpFWOOKsjLVE6CIk,8215
31
31
  vuer/schemas/__pycache__/scene_components.cpython-38.pyc,sha256=eRxB-Tp24yqBR4zbLMGX_4o1P_D-tW1nrDeBPSJKoU4,18135
32
- vuer-0.0.18.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
33
- vuer-0.0.18.dist-info/METADATA,sha256=cbpGK1fH2Wx_FmSLe_X9M59Dk0E_V-7v5FCS-KRfvx0,4277
34
- vuer-0.0.18.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
35
- vuer-0.0.18.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
36
- vuer-0.0.18.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
37
- vuer-0.0.18.dist-info/RECORD,,
32
+ vuer-0.0.19.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
33
+ vuer-0.0.19.dist-info/METADATA,sha256=IY8XfDtcj6-Z8xww_0qN2r9Nh-1_j01_63eGS2OLoto,4277
34
+ vuer-0.0.19.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
35
+ vuer-0.0.19.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
36
+ vuer-0.0.19.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
37
+ vuer-0.0.19.dist-info/RECORD,,
File without changes
File without changes