haiway 0.10.17__py3-none-any.whl → 0.11.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.
haiway/__init__.py CHANGED
@@ -9,7 +9,9 @@ from haiway.context import (
9
9
  MetricsScopeExiting,
10
10
  MissingContext,
11
11
  MissingState,
12
+ ScopeContext,
12
13
  ScopeIdentifier,
14
+ StateContext,
13
15
  ctx,
14
16
  )
15
17
  from haiway.helpers import (
@@ -78,8 +80,10 @@ __all__ = [
78
80
  "MissingContext",
79
81
  "MissingState",
80
82
  "ResultTrace",
83
+ "ScopeContext",
81
84
  "ScopeIdentifier",
82
85
  "State",
86
+ "StateContext",
83
87
  "always",
84
88
  "as_dict",
85
89
  "as_list",
@@ -1,4 +1,4 @@
1
- from haiway.context.access import ctx
1
+ from haiway.context.access import ScopeContext, ctx
2
2
  from haiway.context.disposables import Disposable, Disposables
3
3
  from haiway.context.identifier import ScopeIdentifier
4
4
  from haiway.context.metrics import (
@@ -9,6 +9,7 @@ from haiway.context.metrics import (
9
9
  MetricsScopeEntering,
10
10
  MetricsScopeExiting,
11
11
  )
12
+ from haiway.context.state import StateContext
12
13
  from haiway.context.types import MissingContext, MissingState
13
14
 
14
15
  __all__ = [
@@ -22,6 +23,8 @@ __all__ = [
22
23
  "MetricsScopeExiting",
23
24
  "MissingContext",
24
25
  "MissingState",
26
+ "ScopeContext",
25
27
  "ScopeIdentifier",
28
+ "StateContext",
26
29
  "ctx",
27
30
  ]
haiway/context/access.py CHANGED
@@ -1,4 +1,9 @@
1
- from asyncio import CancelledError, Task, current_task, iscoroutinefunction
1
+ from asyncio import (
2
+ CancelledError,
3
+ Task,
4
+ current_task,
5
+ iscoroutinefunction,
6
+ )
2
7
  from collections.abc import (
3
8
  AsyncGenerator,
4
9
  AsyncIterator,
haiway/utils/queue.py CHANGED
@@ -23,9 +23,6 @@ class AsyncQueue[Element](AsyncIterator[Element]):
23
23
  self._waiting: Future[Element] | None = None
24
24
  self._finish_reason: BaseException | None = None
25
25
 
26
- def __del__(self) -> None:
27
- self.finish()
28
-
29
26
  @property
30
27
  def is_finished(self) -> bool:
31
28
  return self._finish_reason is not None
@@ -34,7 +31,6 @@ class AsyncQueue[Element](AsyncIterator[Element]):
34
31
  self,
35
32
  element: Element,
36
33
  /,
37
- *elements: Element,
38
34
  ) -> None:
39
35
  if self.is_finished:
40
36
  raise RuntimeError("AsyncQueue is already finished")
@@ -45,8 +41,6 @@ class AsyncQueue[Element](AsyncIterator[Element]):
45
41
  else:
46
42
  self._queue.append(element)
47
43
 
48
- self._queue.extend(elements)
49
-
50
44
  def finish(
51
45
  self,
52
46
  exception: BaseException | None = None,
@@ -57,7 +51,17 @@ class AsyncQueue[Element](AsyncIterator[Element]):
57
51
  self._finish_reason = exception or StopAsyncIteration()
58
52
 
59
53
  if self._waiting is not None and not self._waiting.done():
60
- self._waiting.set_exception(self._finish_reason)
54
+ # checking loop only on finish as the rest of operations
55
+ # should always have a valid loop in a typical environment
56
+ # and we are not supporting multithreading yet
57
+ if get_running_loop() is not self._loop:
58
+ self._loop.call_soon_threadsafe(
59
+ self._waiting.set_exception,
60
+ self._finish_reason,
61
+ )
62
+
63
+ else:
64
+ self._waiting.set_exception(self._finish_reason)
61
65
 
62
66
  def cancel(self) -> None:
63
67
  self.finish(exception=CancelledError())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: haiway
3
- Version: 0.10.17
3
+ Version: 0.11.0
4
4
  Summary: Framework for dependency injection and state management within structured concurrency model.
5
5
  Project-URL: Homepage, https://miquido.com
6
6
  Project-URL: Repository, https://github.com/miquido/haiway.git
@@ -1,7 +1,7 @@
1
- haiway/__init__.py,sha256=IEUCyFYKT5IPHnkiUvDVZHdJeHqCaBnG8FhPD20Zgo8,1929
1
+ haiway/__init__.py,sha256=PYMHx7JZwwSsALewho7v6EgIb5MUwYgZEWrVH-OhVx0,2005
2
2
  haiway/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- haiway/context/__init__.py,sha256=eRvuhifx7xCd-_6desgk55idzNpD5S5sprmCfGb3_9M,662
4
- haiway/context/access.py,sha256=Fc2NfoIV2zWE5qPnNgSitK1dy-PME-rJJfUPhoNwJzY,17125
3
+ haiway/context/__init__.py,sha256=feqd0eJnGQwh4B8BZXpS0fQRE-DqoFCFOHipF1jOY8A,762
4
+ haiway/context/access.py,sha256=KeAgxGf78TufqEUSwvw2LPY2aPE00z6xo3hvQ8L6QO4,17146
5
5
  haiway/context/disposables.py,sha256=DZjnMp-wMfF-em2Wjhbm1MvXubNpuzFBT70BQNIxC7M,2019
6
6
  haiway/context/identifier.py,sha256=Fyb6OHx5FPaSLLRK249HUEr_KlBSG5F-eW01Oxg_Ke8,2570
7
7
  haiway/context/logging.py,sha256=ptwgENuyw-WFgokVsYx9OXZGhJENuO_wgfVjcBryUKM,4251
@@ -35,8 +35,8 @@ haiway/utils/freezing.py,sha256=K34ZIMzbkpgkHKH-KF73plEbXExsajNRkRTYp9nJEf4,620
35
35
  haiway/utils/logs.py,sha256=oDsc1ZdqKDjlTlctLbDcp9iX98Acr-1tdw-Pyg3DElo,1577
36
36
  haiway/utils/mimic.py,sha256=BkVjTVP2TxxC8GChPGyDV6UXVwJmiRiSWeOYZNZFHxs,1828
37
37
  haiway/utils/noop.py,sha256=qgbZlOKWY6_23Zs43OLukK2HagIQKRyR04zrFVm5rWI,344
38
- haiway/utils/queue.py,sha256=oQ3GXCJ-PGNtMEr6EPdgqAvYZoj8lAa7Z2drBKBEoBM,2345
39
- haiway-0.10.17.dist-info/METADATA,sha256=IwCgN_53mbzSI8qNibPFrXQT_pwJnA34YxZY1BNdrc8,3858
40
- haiway-0.10.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
- haiway-0.10.17.dist-info/licenses/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
42
- haiway-0.10.17.dist-info/RECORD,,
38
+ haiway/utils/queue.py,sha256=jmz5b4cDvdXpuFnAfrNsGB5wXx4ThCgLHbFlH54o8UY,2657
39
+ haiway-0.11.0.dist-info/METADATA,sha256=HWxQi7lFsvowR9D-wF-zNBHnIfMVq0i5Jlze3BAbVEo,3857
40
+ haiway-0.11.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
41
+ haiway-0.11.0.dist-info/licenses/LICENSE,sha256=GehQEW_I1pkmxkkj3NEa7rCTQKYBn7vTPabpDYJlRuo,1063
42
+ haiway-0.11.0.dist-info/RECORD,,