pyview-web 0.2.5__py3-none-any.whl → 0.2.6__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 pyview-web might be problematic. Click here for more details.

@@ -55,10 +55,10 @@ class BaseEventHandler:
55
55
  else:
56
56
  logging.warning(f"Unhandled event: {event} {payload}")
57
57
 
58
- async def handle_info(self, info: "InfoEvent", socket):
59
- handler = self._info_handlers.get(info.name)
58
+ async def handle_info(self, event: "InfoEvent", socket):
59
+ handler = self._info_handlers.get(event.name)
60
60
 
61
61
  if handler:
62
- return await handler(self, info, socket)
62
+ return await handler(self, event, socket)
63
63
  else:
64
- logging.warning(f"Unhandled info: {info.name} {info}")
64
+ logging.warning(f"Unhandled info: {event.name} {event}")
pyview/live_socket.py CHANGED
@@ -25,8 +25,6 @@ from pyview.async_stream_runner import AsyncStreamRunner
25
25
  if TYPE_CHECKING:
26
26
  from .live_view import LiveView
27
27
 
28
- scheduler = AsyncIOScheduler()
29
- scheduler.start()
30
28
 
31
29
  pub_sub_hub = PubSubHub()
32
30
 
@@ -55,7 +53,13 @@ class ConnectedLiveViewSocket(Generic[T]):
55
53
  upload_manager: UploadManager
56
54
  prev_rendered: Optional[dict[str, Any]] = None
57
55
 
58
- def __init__(self, websocket: WebSocket, topic: str, liveview: LiveView):
56
+ def __init__(
57
+ self,
58
+ websocket: WebSocket,
59
+ topic: str,
60
+ liveview: LiveView,
61
+ scheduler: AsyncIOScheduler,
62
+ ):
59
63
  self.websocket = websocket
60
64
  self.topic = topic
61
65
  self.liveview = liveview
@@ -65,6 +69,7 @@ class ConnectedLiveViewSocket(Generic[T]):
65
69
  self.pending_events = []
66
70
  self.upload_manager = UploadManager()
67
71
  self.stream_runner = AsyncStreamRunner(self)
72
+ self.scheduler = scheduler
68
73
 
69
74
  @property
70
75
  def meta(self) -> PyViewMeta:
@@ -81,13 +86,13 @@ class ConnectedLiveViewSocket(Generic[T]):
81
86
 
82
87
  def schedule_info(self, event, seconds):
83
88
  id = f"{self.topic}:{event}"
84
- scheduler.add_job(
89
+ self.scheduler.add_job(
85
90
  self.send_info, args=[event], id=id, trigger="interval", seconds=seconds
86
91
  )
87
92
  self.scheduled_jobs.append(id)
88
93
 
89
94
  def schedule_info_once(self, event, seconds=None):
90
- scheduler.add_job(
95
+ self.scheduler.add_job(
91
96
  self.send_info,
92
97
  args=[event],
93
98
  trigger="date",
@@ -114,7 +119,7 @@ class ConnectedLiveViewSocket(Generic[T]):
114
119
  except Exception:
115
120
  for id in self.scheduled_jobs:
116
121
  print("Removing job", id)
117
- scheduler.remove_job(id)
122
+ self.scheduler.remove_job(id)
118
123
 
119
124
  async def push_patch(self, path: str, params: dict[str, Any] = {}):
120
125
  # or "replace"
@@ -156,7 +161,7 @@ class ConnectedLiveViewSocket(Generic[T]):
156
161
  async def close(self):
157
162
  self.connected = False
158
163
  for id in self.scheduled_jobs:
159
- scheduler.remove_job(id)
164
+ self.scheduler.remove_job(id)
160
165
  await self.pub_sub.unsubscribe_all_async()
161
166
 
162
167
  try:
pyview/ws_handler.py CHANGED
@@ -8,6 +8,7 @@ from pyview.csrf import validate_csrf_token
8
8
  from pyview.session import deserialize_session
9
9
  from pyview.auth import AuthProviderFactory
10
10
  from pyview.phx_message import parse_message
11
+ from apscheduler.schedulers.asyncio import AsyncIOScheduler
11
12
 
12
13
 
13
14
  class AuthException(Exception):
@@ -19,6 +20,8 @@ class LiveSocketHandler:
19
20
  self.routes = routes
20
21
  self.manager = ConnectionManager()
21
22
  self.sessions = 0
23
+ self.scheduler = AsyncIOScheduler()
24
+ self.scheduler.start()
22
25
 
23
26
  async def check_auth(self, websocket: WebSocket, lv):
24
27
  if not await AuthProviderFactory.get(lv).has_required_auth(websocket):
@@ -43,7 +46,7 @@ class LiveSocketHandler:
43
46
  url = urlparse(payload["url"])
44
47
  lv, path_params = self.routes.get(url.path)
45
48
  await self.check_auth(websocket, lv)
46
- socket = ConnectedLiveViewSocket(websocket, topic, lv)
49
+ socket = ConnectedLiveViewSocket(websocket, topic, lv, self.scheduler)
47
50
 
48
51
  session = {}
49
52
  if "session" in payload:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyview-web
3
- Version: 0.2.5
3
+ Version: 0.2.6
4
4
  Summary: LiveView in Python
5
5
  License: MIT
6
6
  Keywords: web,api,LiveView
@@ -29,14 +29,13 @@ Classifier: Topic :: Software Development :: Libraries
29
29
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
30
30
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
31
31
  Classifier: Typing :: Typed
32
- Requires-Dist: APScheduler (==3.9.1.post1)
32
+ Requires-Dist: APScheduler (==3.11.0)
33
33
  Requires-Dist: click (>=8.1.7,<9.0.0)
34
- Requires-Dist: itsdangerous (>=2.1.2,<3.0.0)
35
- Requires-Dist: markupsafe (>=2.1.2,<3.0.0)
36
- Requires-Dist: psutil (>=5.9.4,<6.0.0)
34
+ Requires-Dist: itsdangerous (>=2.2.0,<3.0.0)
35
+ Requires-Dist: markupsafe (>=3.0.2,<4.0.0)
37
36
  Requires-Dist: pydantic (>=2.9.2,<3.0.0)
38
- Requires-Dist: starlette (==0.40.0)
39
- Requires-Dist: uvicorn (==0.30.6)
37
+ Requires-Dist: starlette (==0.47.1)
38
+ Requires-Dist: uvicorn (==0.34.3)
40
39
  Requires-Dist: wsproto (==1.2.0)
41
40
  Project-URL: Homepage, https://pyview.rocks
42
41
  Project-URL: Repository, https://github.com/ogrodnek/pyview
@@ -13,12 +13,12 @@ pyview/cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
13
13
  pyview/cli/commands/create_view.py,sha256=9hrjc1J1sJHyp3Ihi5ls4Mj19OMNeaj6fpIwDFWrdZ8,5694
14
14
  pyview/cli/main.py,sha256=OEHqNwl9fqIPTI6qy5sLYndPHMEJ3fA9qsjSUuKzYSE,296
15
15
  pyview/csrf.py,sha256=VIURva9EJqXXYGC7engweh3SwDQCnHlhV2zWdcdnFqc,789
16
- pyview/events/BaseEventHandler.py,sha256=0xcjFFMLMN8Aj6toI31vzeYhRQqaX9rm-G7XGXMvqsE,1923
16
+ pyview/events/BaseEventHandler.py,sha256=rBE0z_nN6vIZ8TQ9eRfnCnTEcMOaMX7Na7YgtQmSW3s,1928
17
17
  pyview/events/__init__.py,sha256=oP0SG4Af4uf0GEa0Y_zHYhR7TcBOcXQlTAsgOSaIcC4,156
18
18
  pyview/events/info_event.py,sha256=JOwf3KDodHkmH1MzqTD8sPxs0zbI4t8Ff0rLjwRSe2Y,358
19
19
  pyview/js.py,sha256=E6HMsUfXQjrcLqYq26ieeYuzTjBeZqfJwwOm3uSR4ME,3498
20
20
  pyview/live_routes.py,sha256=IN2Jmy8b1umcfx1R7ZgFXHZNbYDJp_kLIbADtDJknPM,1749
21
- pyview/live_socket.py,sha256=p1KtX9Exwhgsf0yOp3Eb32zdUOo5hSnYDJrpJuTu3QI,5084
21
+ pyview/live_socket.py,sha256=rAa11A7hfbx7DoGC1PQnahxxgGpwOFXwQjYkR9-QtXY,5166
22
22
  pyview/live_view.py,sha256=mwAp7jiABSZCBgYF-GLQCB7zcJ7Wpz9cuC84zjzsp2U,1455
23
23
  pyview/meta.py,sha256=01Z-qldB9jrewmIJHQpUqyIhuHodQGgCvpuY9YM5R6c,74
24
24
  pyview/phx_message.py,sha256=DUdPfl6tlw9K0FNXJ35ehq03JGgynvwA_JItHQ_dxMQ,2007
@@ -48,9 +48,9 @@ pyview/vendor/ibis/nodes.py,sha256=TgFt4q5MrVW3gC3PVitrs2LyXKllRveooM7XKydNATk,2
48
48
  pyview/vendor/ibis/template.py,sha256=6XJXnztw87CrOaKeW3e18LL0fNM8AI6AaK_QgMdb7ew,2353
49
49
  pyview/vendor/ibis/tree.py,sha256=hg8f-fKHeo6DE8R-QgAhdvEaZ8rKyz7p0nGwPy0CBTs,2509
50
50
  pyview/vendor/ibis/utils.py,sha256=nLSaxPR9vMphzV9qinlz_Iurv9c49Ps6Knv8vyNlewU,2768
51
- pyview/ws_handler.py,sha256=CY1iDx5GETjIkqhgFbo2fkE3FhrqucSdg4AjuJ2P0Qg,9041
52
- pyview_web-0.2.5.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
53
- pyview_web-0.2.5.dist-info/METADATA,sha256=3g39-VhWx0gWkq1B46NAkTTTDSqnOr692TkFZtgOrNo,5243
54
- pyview_web-0.2.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
- pyview_web-0.2.5.dist-info/entry_points.txt,sha256=GAT-ic-VYmmSMUSUVKdV1bp4w-vgEeVP-XzElvarQ9U,42
56
- pyview_web-0.2.5.dist-info/RECORD,,
51
+ pyview/ws_handler.py,sha256=qe_rQV5z4GTZOgMDSTC29zv8VrUJ0B5AApGdQ9GzrV0,9192
52
+ pyview_web-0.2.6.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
53
+ pyview_web-0.2.6.dist-info/METADATA,sha256=Iwe5cP1CvsCCvf-2qi077zYcxFj5HhTJwtD10yZqhcM,5199
54
+ pyview_web-0.2.6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
55
+ pyview_web-0.2.6.dist-info/entry_points.txt,sha256=GAT-ic-VYmmSMUSUVKdV1bp4w-vgEeVP-XzElvarQ9U,42
56
+ pyview_web-0.2.6.dist-info/RECORD,,