hmr 0.4.0.4__py3-none-any.whl → 0.4.1.1__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.
- {hmr-0.4.0.4.dist-info → hmr-0.4.1.1.dist-info}/METADATA +1 -1
- {hmr-0.4.0.4.dist-info → hmr-0.4.1.1.dist-info}/RECORD +7 -7
- reactivity/hmr/api.py +14 -4
- reactivity/hmr/core.py +2 -3
- reactivity/hmr/hooks.py +19 -0
- {hmr-0.4.0.4.dist-info → hmr-0.4.1.1.dist-info}/WHEEL +0 -0
- {hmr-0.4.0.4.dist-info → hmr-0.4.1.1.dist-info}/entry_points.txt +0 -0
@@ -1,14 +1,14 @@
|
|
1
|
-
hmr-0.4.
|
2
|
-
hmr-0.4.
|
3
|
-
hmr-0.4.
|
1
|
+
hmr-0.4.1.1.dist-info/METADATA,sha256=AZJ6lFoPbTauSV8qwcFBBjMULXEErXov3sU9e13l-cQ,260
|
2
|
+
hmr-0.4.1.1.dist-info/WHEEL,sha256=tSfRZzRHthuv7vxpI4aehrdN9scLjk-dCJkPLzkHxGg,90
|
3
|
+
hmr-0.4.1.1.dist-info/entry_points.txt,sha256=g_T0uJ43WgsdG14kkkdaBQuIL0HO-m1qvtjXMP6d060,59
|
4
4
|
reactivity/__init__.py,sha256=pX-RUzkezCC1x4eOWGxNhXbwrbvBLP_3pQuZr9eZz1Y,300
|
5
5
|
reactivity/functional.py,sha256=U06vshcVhZ0sb218gcmHtEhfgTNAGtQ7zyvPz2w5qKM,1292
|
6
6
|
reactivity/helpers.py,sha256=1KCpre2HTFZrngEKkI2HwSFMkCmsUCq2aPEbp0y3kKg,5140
|
7
7
|
reactivity/hmr/__init__.py,sha256=S5ZIHqCRpevdzWuhS0aCua_S8F0LkK0YNg6IgeTScFQ,177
|
8
8
|
reactivity/hmr/__main__.py,sha256=uIcyjR5gMFIXH_3hS0B3SD00RirVf7GIct-uItx675o,64
|
9
|
-
reactivity/hmr/api.py,sha256=
|
10
|
-
reactivity/hmr/core.py,sha256=
|
11
|
-
reactivity/hmr/hooks.py,sha256
|
9
|
+
reactivity/hmr/api.py,sha256=Esb1fYiBW0SLxQ0MPXby25ZgIIZhIp-M3b2KiqpffmU,2094
|
10
|
+
reactivity/hmr/core.py,sha256=S6sqMkMKdc6DSNt6I9ZZWbR6bH_069MQ-eBUU_4qdDY,11584
|
11
|
+
reactivity/hmr/hooks.py,sha256=jIFpe4CNxfaS9RcR4OIodx_sOZlnJ_IA1T1RtHPXhwU,945
|
12
12
|
reactivity/hmr/utils.py,sha256=-PO-LMP4sc3IP-Bn_baq2w9IFWBZ3zGesgRn5wR6bS0,1555
|
13
13
|
reactivity/primitives.py,sha256=mB6cbHKDqtilOfgaEhshtRWJq9s0nPEKqRK0hfCoyFE,5671
|
14
|
-
hmr-0.4.
|
14
|
+
hmr-0.4.1.1.dist-info/RECORD,,
|
reactivity/hmr/api.py
CHANGED
@@ -29,10 +29,11 @@ class SyncReloaderAPI(SyncReloader, LifecycleMixin):
|
|
29
29
|
self.clean_up()
|
30
30
|
|
31
31
|
async def __aenter__(self):
|
32
|
-
from asyncio import ensure_future, to_thread
|
32
|
+
from asyncio import ensure_future, sleep, to_thread
|
33
33
|
|
34
34
|
await to_thread(self.run_with_hooks)
|
35
35
|
self.future = ensure_future(to_thread(self.start_watching))
|
36
|
+
await sleep(0)
|
36
37
|
return super()
|
37
38
|
|
38
39
|
async def __aexit__(self, *_):
|
@@ -44,11 +45,19 @@ class SyncReloaderAPI(SyncReloader, LifecycleMixin):
|
|
44
45
|
class AsyncReloaderAPI(AsyncReloader, LifecycleMixin):
|
45
46
|
def __enter__(self):
|
46
47
|
from asyncio import run
|
47
|
-
from threading import Thread
|
48
|
+
from threading import Event, Thread
|
48
49
|
|
49
50
|
self.run_with_hooks()
|
50
|
-
|
51
|
+
|
52
|
+
e = Event()
|
53
|
+
|
54
|
+
async def task():
|
55
|
+
e.set()
|
56
|
+
await self.start_watching()
|
57
|
+
|
58
|
+
self.thread = Thread(target=lambda: run(task()))
|
51
59
|
self.thread.start()
|
60
|
+
e.wait()
|
52
61
|
return super()
|
53
62
|
|
54
63
|
def __exit__(self, *_):
|
@@ -57,10 +66,11 @@ class AsyncReloaderAPI(AsyncReloader, LifecycleMixin):
|
|
57
66
|
self.clean_up()
|
58
67
|
|
59
68
|
async def __aenter__(self):
|
60
|
-
from asyncio import ensure_future, to_thread
|
69
|
+
from asyncio import ensure_future, sleep, to_thread
|
61
70
|
|
62
71
|
await to_thread(self.run_with_hooks)
|
63
72
|
self.future = ensure_future(self.start_watching())
|
73
|
+
await sleep(0)
|
64
74
|
return super()
|
65
75
|
|
66
76
|
async def __aexit__(self, *_):
|
reactivity/hmr/core.py
CHANGED
@@ -122,8 +122,7 @@ class ReactiveModule(ModuleType):
|
|
122
122
|
try:
|
123
123
|
return self.__namespace_proxy[name]
|
124
124
|
except KeyError as e:
|
125
|
-
|
126
|
-
if caller != "importlib._bootstrap" and (getattr := self.__namespace_proxy.get("__getattr__")):
|
125
|
+
if name != "__path__" and (getattr := self.__namespace_proxy.get("__getattr__")):
|
127
126
|
return getattr(name)
|
128
127
|
raise AttributeError(*e.args) from e
|
129
128
|
|
@@ -340,4 +339,4 @@ def cli():
|
|
340
339
|
SyncReloader(entry).keep_watching_until_interrupt()
|
341
340
|
|
342
341
|
|
343
|
-
__version__ = "0.4.
|
342
|
+
__version__ = "0.4.1.1"
|
reactivity/hmr/hooks.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from collections.abc import Callable
|
2
|
+
from contextlib import contextmanager
|
2
3
|
from typing import Any
|
3
4
|
|
4
5
|
pre_reload_hooks: dict[str, Callable[[], Any]] = {}
|
@@ -15,6 +16,24 @@ def post_reload[T](func: Callable[[], T]) -> Callable[[], T]:
|
|
15
16
|
return func
|
16
17
|
|
17
18
|
|
19
|
+
@contextmanager
|
20
|
+
def use_pre_reload(func):
|
21
|
+
pre_reload(func)
|
22
|
+
try:
|
23
|
+
yield func
|
24
|
+
finally:
|
25
|
+
pre_reload_hooks.pop(func.__name__, None)
|
26
|
+
|
27
|
+
|
28
|
+
@contextmanager
|
29
|
+
def use_post_reload(func):
|
30
|
+
post_reload(func)
|
31
|
+
try:
|
32
|
+
yield func
|
33
|
+
finally:
|
34
|
+
post_reload_hooks.pop(func.__name__, None)
|
35
|
+
|
36
|
+
|
18
37
|
def call_pre_reload_hooks():
|
19
38
|
for func in pre_reload_hooks.values():
|
20
39
|
func()
|
File without changes
|
File without changes
|