payi 0.1.0a49__py3-none-any.whl → 0.1.0a50__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 payi might be problematic. Click here for more details.
- payi/_utils/_sync.py +17 -2
- payi/_version.py +1 -1
- {payi-0.1.0a49.dist-info → payi-0.1.0a50.dist-info}/METADATA +1 -1
- {payi-0.1.0a49.dist-info → payi-0.1.0a50.dist-info}/RECORD +6 -6
- {payi-0.1.0a49.dist-info → payi-0.1.0a50.dist-info}/WHEEL +0 -0
- {payi-0.1.0a49.dist-info → payi-0.1.0a50.dist-info}/licenses/LICENSE +0 -0
payi/_utils/_sync.py
CHANGED
|
@@ -7,16 +7,20 @@ import contextvars
|
|
|
7
7
|
from typing import Any, TypeVar, Callable, Awaitable
|
|
8
8
|
from typing_extensions import ParamSpec
|
|
9
9
|
|
|
10
|
+
import anyio
|
|
11
|
+
import sniffio
|
|
12
|
+
import anyio.to_thread
|
|
13
|
+
|
|
10
14
|
T_Retval = TypeVar("T_Retval")
|
|
11
15
|
T_ParamSpec = ParamSpec("T_ParamSpec")
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
if sys.version_info >= (3, 9):
|
|
15
|
-
|
|
19
|
+
_asyncio_to_thread = asyncio.to_thread
|
|
16
20
|
else:
|
|
17
21
|
# backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
|
|
18
22
|
# for Python 3.8 support
|
|
19
|
-
async def
|
|
23
|
+
async def _asyncio_to_thread(
|
|
20
24
|
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
|
|
21
25
|
) -> Any:
|
|
22
26
|
"""Asynchronously run function *func* in a separate thread.
|
|
@@ -34,6 +38,17 @@ else:
|
|
|
34
38
|
return await loop.run_in_executor(None, func_call)
|
|
35
39
|
|
|
36
40
|
|
|
41
|
+
async def to_thread(
|
|
42
|
+
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
|
|
43
|
+
) -> T_Retval:
|
|
44
|
+
if sniffio.current_async_library() == "asyncio":
|
|
45
|
+
return await _asyncio_to_thread(func, *args, **kwargs)
|
|
46
|
+
|
|
47
|
+
return await anyio.to_thread.run_sync(
|
|
48
|
+
functools.partial(func, *args, **kwargs),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
37
52
|
# inspired by `asyncer`, https://github.com/tiangolo/asyncer
|
|
38
53
|
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
|
|
39
54
|
"""
|
payi/_version.py
CHANGED
|
@@ -11,14 +11,14 @@ payi/_resource.py,sha256=j2jIkTr8OIC8sU6-05nxSaCyj4MaFlbZrwlyg4_xJos,1088
|
|
|
11
11
|
payi/_response.py,sha256=CfrNS_3wbL8o9dRyRVfZQ5E1GUlA4CUIUEK8olmfGqE,28777
|
|
12
12
|
payi/_streaming.py,sha256=Z_wIyo206T6Jqh2rolFg2VXZgX24PahLmpURp0-NssU,10092
|
|
13
13
|
payi/_types.py,sha256=2mbMK86K3W1aMTW7sOGQ-VND6-A2IuXKm8p4sYFztBU,6141
|
|
14
|
-
payi/_version.py,sha256=
|
|
14
|
+
payi/_version.py,sha256=eV5t7glu1rddfBj2KaJZbWBaWyb8PZ31PrzKJnhd1mc,165
|
|
15
15
|
payi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
payi/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
|
|
17
17
|
payi/_utils/_logs.py,sha256=fmnf5D9TOgkgZKfgYmSa3PiUc3SZgkchn6CzJUeo0SQ,768
|
|
18
18
|
payi/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
|
|
19
19
|
payi/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
|
|
20
20
|
payi/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
|
|
21
|
-
payi/_utils/_sync.py,sha256=
|
|
21
|
+
payi/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
|
|
22
22
|
payi/_utils/_transform.py,sha256=tsSFOIZ7iczaUsMSGBD_iSFOOdUyT2xtkcq1xyF0L9o,13986
|
|
23
23
|
payi/_utils/_typing.py,sha256=nTJz0jcrQbEgxwy4TtAkNxuU0QHHlmc6mQtA6vIR8tg,4501
|
|
24
24
|
payi/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
|
|
@@ -112,7 +112,7 @@ payi/types/requests/request_result.py,sha256=phYQiqhwNaR9igP-Fhs34Y-__dlT7L4wq-r
|
|
|
112
112
|
payi/types/shared/__init__.py,sha256=-xz5dxK5LBjLnsi2LpLq5btaGDFp-mSjJ0y2qKy0Yus,264
|
|
113
113
|
payi/types/shared/evaluation_response.py,sha256=ejEToMA57PUu1SldEtJ5z9r4fAO3U0tvdjbsyIoVX1s,214
|
|
114
114
|
payi/types/shared/pay_i_common_models_budget_management_cost_details_base.py,sha256=XmIzJXy4zAi-mfrDvEXiYjO3qF1EvugGUl-Gijj4TA4,268
|
|
115
|
-
payi-0.1.
|
|
116
|
-
payi-0.1.
|
|
117
|
-
payi-0.1.
|
|
118
|
-
payi-0.1.
|
|
115
|
+
payi-0.1.0a50.dist-info/METADATA,sha256=iM3Z4_67ypMAHvmAMATNobzasM07vzfSO1Vj3h9cYLY,12660
|
|
116
|
+
payi-0.1.0a50.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
117
|
+
payi-0.1.0a50.dist-info/licenses/LICENSE,sha256=CQt03aM-P4a3Yg5qBg3JSLVoQS3smMyvx7tYg_6V7Gk,11334
|
|
118
|
+
payi-0.1.0a50.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|