pico-ioc 2.2.0__py3-none-any.whl → 2.2.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.
pico_ioc/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = '2.2.0'
1
+ __version__ = '2.2.1'
pico_ioc/aop.py CHANGED
@@ -145,23 +145,25 @@ class UnifiedComponentProxy:
145
145
  return
146
146
 
147
147
  lock = object.__getattribute__(self, "_lock")
148
- tgt = object.__getattribute__(self, "_target")
149
- if tgt is not None:
150
- return
151
148
 
152
- creator = object.__getattribute__(self, "_creator")
153
- container = object.__getattribute__(self, "_container")
154
-
155
- tgt = creator()
156
-
149
+ with lock:
150
+ # Double-check inside lock to prevent race condition
151
+ tgt = object.__getattribute__(self, "_target")
152
+ if tgt is not None:
153
+ return
154
+
155
+ creator = object.__getattribute__(self, "_creator")
156
+ container = object.__getattribute__(self, "_container")
157
+
158
+ tgt = creator()
159
+ object.__setattr__(self, "_target", tgt)
160
+
161
+ # Run configure methods outside the lock to avoid blocking
157
162
  if container and hasattr(container, "_run_configure_methods"):
158
163
  res = container._run_configure_methods(tgt)
159
164
  if inspect.isawaitable(res):
160
165
  await res
161
166
 
162
- with lock:
163
- object.__setattr__(self, "_target", tgt)
164
-
165
167
  def _scope_signature(self) -> Tuple[Any, ...]:
166
168
  container = object.__getattribute__(self, "_container")
167
169
  key = object.__getattribute__(self, "_component_key")
pico_ioc/container.py CHANGED
@@ -438,7 +438,7 @@ class PicoContainer:
438
438
  pid = _node_id(parent)
439
439
  for child in deps:
440
440
  cid = _node_id(child)
441
- lines.append(f" {pid} -> {child};")
441
+ lines.append(f" {pid} -> {cid};")
442
442
 
443
443
  lines.append("}")
444
444
 
pico_ioc/scope.py CHANGED
@@ -1,9 +1,12 @@
1
1
  import contextvars
2
2
  import inspect
3
+ import logging
3
4
  from typing import Any, Dict, Optional, Tuple
4
5
  from collections import OrderedDict
5
6
  from .exceptions import ScopeError
6
7
 
8
+ _logger = logging.getLogger(__name__)
9
+
7
10
  class ScopeProtocol:
8
11
  def get_id(self) -> Any | None: ...
9
12
 
@@ -108,10 +111,15 @@ class ScopedCaches:
108
111
  if meta.get("cleanup", False):
109
112
  try:
110
113
  m()
111
- except Exception:
112
- pass
113
- except Exception:
114
- pass
114
+ except Exception as e:
115
+ _logger.warning(
116
+ "Cleanup method %s.%s failed: %s",
117
+ type(obj).__name__,
118
+ getattr(m, "__name__", "<unknown>"),
119
+ e
120
+ )
121
+ except Exception as e:
122
+ _logger.debug("Failed to inspect object for cleanup: %s", e)
115
123
 
116
124
  def cleanup_scope(self, scope_name: str, scope_id: Any) -> None:
117
125
  bucket = self._by_scope.get(scope_name)
@@ -123,8 +131,8 @@ class ScopedCaches:
123
131
  try:
124
132
  for _, obj in container.items():
125
133
  self._cleanup_object(obj)
126
- except Exception:
127
- pass
134
+ except Exception as e:
135
+ _logger.debug("Failed to cleanup container: %s", e)
128
136
 
129
137
  def for_scope(self, scopes: ScopeManager, scope: str) -> ComponentContainer:
130
138
  if scope == "singleton":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pico-ioc
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: A minimalist, zero-dependency Inversion of Control (IoC) container for Python.
5
5
  Author-email: David Perez Cabrera <dperezcabrera@gmail.com>
6
6
  License: MIT License
@@ -347,7 +347,7 @@ tox
347
347
 
348
348
  ## 🧾 Changelog
349
349
 
350
- See [CHANGELOG.md](https://www.google.com/search?q=./CHANGELOG.md) — Significant redesigns and features in v2.0+.
350
+ See [CHANGELOG.md](./CHANGELOG.md) — Significant redesigns and features in v2.0+.
351
351
 
352
352
  -----
353
353
 
@@ -1,14 +1,14 @@
1
1
  pico_ioc/__init__.py,sha256=MDneoBBB0JHD_o0_xzkOUeW4e3XjDJSaGMNTb5miBqw,2453
2
- pico_ioc/_version.py,sha256=Vyf6P6UCZKFeQtRzYujPmFfdlqSfnc01VEMWE3O0ZrA,22
2
+ pico_ioc/_version.py,sha256=-7agX4LcQ0956RU4mY0EYyxYQU9llH7JklZOsqoujdU,22
3
3
  pico_ioc/analysis.py,sha256=cxlg3F3bwRIb-kVIqHp1RLYj-sk-GuIgCChE-pf0a7c,4189
4
- pico_ioc/aop.py,sha256=VkmLzoztPbFjLIqBmXohcCNd4w6UC9ZrqYOE8DsMQ7I,14417
4
+ pico_ioc/aop.py,sha256=cD4f-xwWOn93XE0q_J5LNepocimd_FOUKT2IABa8erU,14548
5
5
  pico_ioc/api.py,sha256=KlZjI_4pJfD_1T32DgmOykii6L1V-5Xtcynd5d57YIA,6400
6
6
  pico_ioc/component_scanner.py,sha256=rRZSQbJ7SkssJ5SJBr_m2ih-lpFvVnDQpt-JrYH5Xsg,8999
7
7
  pico_ioc/config_builder.py,sha256=7kcYIq1Yrb46Tic7uLeaCDvLA-Sa_p1PIoGF00mivso,2848
8
8
  pico_ioc/config_registrar.py,sha256=34iNQY1TUEPTXbb-QV1T-c5VKAn18hBcNt5MLhzDSfY,8456
9
9
  pico_ioc/config_runtime.py,sha256=qdPIbGMXOf6KWMM7cva6W-hhbhybEY0swZN01R1emCg,12756
10
10
  pico_ioc/constants.py,sha256=AhIt0ieDZ9Turxb_YbNzj11wUbBbzjKfWh1BDlSx2Nw,183
11
- pico_ioc/container.py,sha256=ipTpMwtCYuYfmJCjd7dfEtFFVR1PG0C1lZQp-wJ_UHw,21512
11
+ pico_ioc/container.py,sha256=scg0EvYubvWM8NkaYag6MrmOZUfeDhOg7Vq0pAdnWA4,21510
12
12
  pico_ioc/decorators.py,sha256=ru_YeqyJ3gbfb6M8WeJZlBxfcBBEuGDvxpHJGzU6FIs,6412
13
13
  pico_ioc/dependency_validator.py,sha256=BIR6pKntACiabF6CjNZ3m00RMnet9BPK1_9y1iCJ5KQ,4144
14
14
  pico_ioc/event_bus.py,sha256=NSfmFPX6Zm2OmMJz16gJFYMhh65iI0n9UlC9M8GmO0c,8428
@@ -17,9 +17,9 @@ pico_ioc/factory.py,sha256=oJXx_BYJuvV8oxYzs5I3gx9WM6uLYZ8GCc43gukNanc,1671
17
17
  pico_ioc/locator.py,sha256=JD6psgdGGsBoCwov-G76BrmTfKUoJ22sdwa6wVdmQV8,5064
18
18
  pico_ioc/provider_selector.py,sha256=pU7NbI5vifvUlJEjlRJmvveQUZVD47T24QmiP0CHRw0,1213
19
19
  pico_ioc/registrar.py,sha256=0abgnJMJrEvEyqsvxBNTi6wl0iJHHjSaw75IuqGk56c,8531
20
- pico_ioc/scope.py,sha256=TFchqFE9ooDCtYV_9YaLdeJDMtmLdNbB63nbZp-AqI8,6349
21
- pico_ioc-2.2.0.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
22
- pico_ioc-2.2.0.dist-info/METADATA,sha256=HnQ9xsjsyPFA7zCIkzkkHLSngVut4bZQUjHHBsk9PXI,12901
23
- pico_ioc-2.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- pico_ioc-2.2.0.dist-info/top_level.txt,sha256=_7_RLu616z_dtRw16impXn4Mw8IXe2J4BeX5912m5dQ,9
25
- pico_ioc-2.2.0.dist-info/RECORD,,
20
+ pico_ioc/scope.py,sha256=0Jb8o_yjnbZR1vJdzTvuMHf5fy0Sq3q8O5A16hb1pbE,6765
21
+ pico_ioc-2.2.1.dist-info/licenses/LICENSE,sha256=N1_nOvHTM6BobYnOTNXiQkroDqCEi6EzfGBv8lWtyZ0,1077
22
+ pico_ioc-2.2.1.dist-info/METADATA,sha256=ZIhyfQH8ALbe1O8DodGebB1e_zMP38NvmQ18V8MUsl4,12869
23
+ pico_ioc-2.2.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
24
+ pico_ioc-2.2.1.dist-info/top_level.txt,sha256=_7_RLu616z_dtRw16impXn4Mw8IXe2J4BeX5912m5dQ,9
25
+ pico_ioc-2.2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5