python-injection 0.19.6__py3-none-any.whl → 0.19.8__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.
- injection/_core/asfunction.py +1 -2
- injection/_core/common/threading.py +6 -2
- {python_injection-0.19.6.dist-info → python_injection-0.19.8.dist-info}/METADATA +9 -3
- {python_injection-0.19.6.dist-info → python_injection-0.19.8.dist-info}/RECORD +6 -6
- {python_injection-0.19.6.dist-info → python_injection-0.19.8.dist-info}/WHEEL +0 -0
- {python_injection-0.19.6.dist-info → python_injection-0.19.8.dist-info}/licenses/LICENSE +0 -0
injection/_core/asfunction.py
CHANGED
@@ -2,7 +2,6 @@ from abc import abstractmethod
|
|
2
2
|
from collections.abc import Callable
|
3
3
|
from functools import wraps
|
4
4
|
from inspect import iscoroutinefunction
|
5
|
-
from types import MethodType
|
6
5
|
from typing import Any, Protocol, runtime_checkable
|
7
6
|
|
8
7
|
from injection._core.common.asynchronous import Caller
|
@@ -30,7 +29,7 @@ def asfunction[**P, T](
|
|
30
29
|
module = module or mod()
|
31
30
|
|
32
31
|
def decorator(wp: AsFunctionWrappedType[P, T]) -> Callable[P, T]:
|
33
|
-
fake_method =
|
32
|
+
fake_method = wp.call.__get__(NotImplemented)
|
34
33
|
factory: Caller[..., AsFunctionCallable[P, T]] = module.make_injected_function(
|
35
34
|
wp,
|
36
35
|
threadsafe=threadsafe,
|
@@ -1,7 +1,11 @@
|
|
1
1
|
from contextlib import nullcontext
|
2
|
+
from os import getenv
|
2
3
|
from threading import RLock
|
3
|
-
from typing import Any, ContextManager
|
4
|
+
from typing import Any, ContextManager, Final
|
5
|
+
|
6
|
+
_PYTHON_INJECTION_THREADSAFE: Final[bool] = bool(getenv("PYTHON_INJECTION_THREADSAFE"))
|
4
7
|
|
5
8
|
|
6
9
|
def get_lock(threadsafe: bool | None = None) -> ContextManager[Any]:
|
7
|
-
|
10
|
+
cond = _PYTHON_INJECTION_THREADSAFE if threadsafe is None else threadsafe
|
11
|
+
return RLock() if cond else nullcontext()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: python-injection
|
3
|
-
Version: 0.19.
|
3
|
+
Version: 0.19.8
|
4
4
|
Summary: Fast and easy dependency injection framework.
|
5
5
|
Project-URL: Repository, https://github.com/100nm/python-injection
|
6
6
|
Author: remimd
|
@@ -92,8 +92,14 @@ if __name__ == "__main__":
|
|
92
92
|
|
93
93
|
## Resources
|
94
94
|
|
95
|
-
> ⚠️ The package isn't threadsafe, for better performance in single-threaded applications and those using
|
96
|
-
>
|
95
|
+
> ⚠️ The package isn't threadsafe by default, for better performance in single-threaded applications and those using
|
96
|
+
> `asyncio`.
|
97
|
+
>
|
98
|
+
> Non-threadsafe functions are those that resolve dependencies or define scopes. They all come with an optional
|
99
|
+
> parameter `threadsafe`.
|
100
|
+
>
|
101
|
+
> You can set `PYTHON_INJECTION_THREADSAFE=1` in environment variables to make the package fully threadsafe. The
|
102
|
+
> environment variable is resolved at the **Python module level**, so be careful if the variable is defined dynamically.
|
97
103
|
|
98
104
|
* [**Basic usage**](https://github.com/100nm/python-injection/tree/prod/documentation/basic-usage.md)
|
99
105
|
* [**Scoped dependencies**](https://github.com/100nm/python-injection/tree/prod/documentation/scoped-dependencies.md)
|
@@ -5,7 +5,7 @@ injection/exceptions.py,sha256=v57yMujiq6H_zwwn30A8UYEZX9R9k-bY8FnsdaimPM4,1025
|
|
5
5
|
injection/loaders.py,sha256=gKlJfe9nXCuB8r6j0RF9_2FHC6YplM8GQYsgRqyxYw8,7257
|
6
6
|
injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
injection/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
injection/_core/asfunction.py,sha256=
|
8
|
+
injection/_core/asfunction.py,sha256=Fb-05PAi0XOV0w2Hg5OGWuAVDNBBFL_WnpH7tteuaKI,1734
|
9
9
|
injection/_core/descriptors.py,sha256=1OX6JnM8Ux14vW1JSW3FzPgKc2VMTKqJUYBGT3Ypafg,800
|
10
10
|
injection/_core/injectables.py,sha256=fxhiGv7qTCbUunhhd6a3ahosFmgznUFsEvqlwxi4gS4,6098
|
11
11
|
injection/_core/module.py,sha256=kUOzW7CYf3oGgVBhwJT1-05UI-HLH2N_E4o17Fyw1g4,32721
|
@@ -17,14 +17,14 @@ injection/_core/common/event.py,sha256=XjzV8gxtGlGvzZs_ykvoC60qmdpd3RN08Eiqz5QUw
|
|
17
17
|
injection/_core/common/invertible.py,sha256=gA_vw5nBjgp_w9MrDK5jMO8lhuOQWON8BbPpKzEuIY0,502
|
18
18
|
injection/_core/common/key.py,sha256=ghkZD-Y8Moz6SEPNgMh3xgsZUjDVq-XYAmXaCu5VuCA,80
|
19
19
|
injection/_core/common/lazy.py,sha256=hZvz9LhlYxVkD_D8VBAvQmy7YuVaaw075jq0XM0w9_Y,1193
|
20
|
-
injection/_core/common/threading.py,sha256=
|
20
|
+
injection/_core/common/threading.py,sha256=LR5_wiwZ9_YrcOOKg0qtwbe1YqYdYP57-PAFIe4bknM,415
|
21
21
|
injection/_core/common/type.py,sha256=U7PtuH-FuMgw75LB7xy-arJRJXojxsJDQbhnTqA4P-o,2567
|
22
22
|
injection/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
23
23
|
injection/ext/fastapi.py,sha256=fiy3-mZIIwGcql3Y5ekFX8_7hALzqXP5u40qbtNE73o,1441
|
24
24
|
injection/ext/fastapi.pyi,sha256=HLs7mfruIEFRrN_Xf8oCvSa4qwHWfwm6HHU_KMedXkE,185
|
25
25
|
injection/testing/__init__.py,sha256=bJ7WXBXrw4rHc91AFVFnOwFLWOlpvX9Oh2SnRQ_NESo,919
|
26
26
|
injection/testing/__init__.pyi,sha256=raGsGlxwbz3jkzJwA_5oCIE1emWINjT2UuwzbnqRb-0,577
|
27
|
-
python_injection-0.19.
|
28
|
-
python_injection-0.19.
|
29
|
-
python_injection-0.19.
|
30
|
-
python_injection-0.19.
|
27
|
+
python_injection-0.19.8.dist-info/METADATA,sha256=tBq2cdbNYZ_fXbm-ErFJAIv1KvRLxGHnc5CU2J9DTvE,4613
|
28
|
+
python_injection-0.19.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
29
|
+
python_injection-0.19.8.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
|
30
|
+
python_injection-0.19.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|