asyncer 0.0.4__tar.gz → 0.0.6.dev1__tar.gz
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.
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/PKG-INFO +7 -11
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/asyncer/__init__.py +1 -1
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/asyncer/_main.py +9 -2
- asyncer-0.0.6.dev1/docs_src/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/asyncify/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/asyncify/tutorial001.py +16 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/asyncify/tutorial002.py +17 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/first_steps/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/first_steps/tutorial001.py +15 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/runnify/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/runnify/tutorial001.py +16 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify/tutorial001.py +19 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify/tutorial002.py +21 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify_return/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify_return/tutorial001.py +27 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify_return/tutorial002.py +28 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/soonify_return/tutorial003.py +30 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/syncify/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/syncify/tutorial001.py +23 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/syncify_no_raise/__init__.py +0 -0
- asyncer-0.0.6.dev1/docs_src/tutorial/syncify_no_raise/tutorial001.py +29 -0
- asyncer-0.0.6.dev1/pyproject.toml +111 -0
- asyncer-0.0.6.dev1/requirements-docs.txt +17 -0
- asyncer-0.0.6.dev1/requirements-tests.txt +6 -0
- asyncer-0.0.6.dev1/requirements.txt +6 -0
- asyncer-0.0.6.dev1/scripts/docs-live.sh +7 -0
- asyncer-0.0.6.dev1/scripts/format.sh +5 -0
- asyncer-0.0.6.dev1/scripts/lint.sh +8 -0
- asyncer-0.0.6.dev1/scripts/publish.sh +5 -0
- asyncer-0.0.6.dev1/scripts/test-files.sh +7 -0
- asyncer-0.0.6.dev1/scripts/test.sh +9 -0
- asyncer-0.0.6.dev1/tests/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/conftest.py +13 -0
- asyncer-0.0.6.dev1/tests/test_others.py +5 -0
- asyncer-0.0.6.dev1/tests/test_syncify_no_raise.py +87 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_asyncify/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_asyncify/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_asyncify/test_tutorial002.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_first_steps/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_first_steps/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_runnify/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_runnify/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify/test_tutorial002.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify_return/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify_return/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify_return/test_tutorial002.py +28 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_soonify_return/test_tutorial003.py +20 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_syncify/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_syncify/test_tutorial001.py +15 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_syncify_no_raise/__init__.py +0 -0
- asyncer-0.0.6.dev1/tests/test_tutorial/test_syncify_no_raise/test_tutorial001.py +15 -0
- asyncer-0.0.4/pyproject.toml +0 -101
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/LICENSE +0 -0
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/README.md +0 -0
- {asyncer-0.0.4 → asyncer-0.0.6.dev1}/asyncer/py.typed +0 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: asyncer
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.6.dev1
|
|
4
4
|
Summary: Asyncer, async and await, focused on developer experience.
|
|
5
|
-
|
|
6
|
-
License: MIT
|
|
7
|
-
Author: Sebastián Ramírez
|
|
8
|
-
Author-email: tiangolo@gmail.com
|
|
9
|
-
Requires-Python: >=3.8,<4.0
|
|
5
|
+
Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= <tiangolo@gmail.com>
|
|
10
6
|
Classifier: Development Status :: 4 - Beta
|
|
11
7
|
Classifier: Framework :: AsyncIO
|
|
12
8
|
Classifier: Framework :: Trio
|
|
@@ -16,19 +12,20 @@ Classifier: Intended Audience :: Information Technology
|
|
|
16
12
|
Classifier: Intended Audience :: Science/Research
|
|
17
13
|
Classifier: Intended Audience :: System Administrators
|
|
18
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
16
|
Classifier: Programming Language :: Python :: 3.8
|
|
21
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
22
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
23
19
|
Classifier: Programming Language :: Python :: 3.11
|
|
24
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
26
21
|
Classifier: Topic :: Internet
|
|
27
22
|
Classifier: Typing :: Typed
|
|
28
|
-
|
|
29
|
-
Requires-Dist: typing_extensions (>=4.8.0,<5.0.0) ; python_version < "3.10"
|
|
23
|
+
Project-URL: Homepage, https://github.com/tiangolo/asyncer
|
|
30
24
|
Project-URL: Documentation, https://asyncer.tiangolo.com
|
|
31
25
|
Project-URL: Repository, https://github.com/tiangolo/asyncer
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: anyio<5.0,>=3.4.0
|
|
28
|
+
Requires-Dist: typing_extensions>=4.8.0; python_version < "3.10"
|
|
32
29
|
Description-Content-Type: text/markdown
|
|
33
30
|
|
|
34
31
|
<p align="center">
|
|
@@ -156,4 +153,3 @@ Everything in **Asyncer** is designed to get the best **developer experience** p
|
|
|
156
153
|
## License
|
|
157
154
|
|
|
158
155
|
This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/asyncer/blob/main/LICENSE).
|
|
159
|
-
|
|
@@ -26,7 +26,9 @@ from anyio.abc import TaskGroup as _TaskGroup
|
|
|
26
26
|
|
|
27
27
|
# This was obtained with: from anyio._core._eventloop import get_asynclib
|
|
28
28
|
# Removed in https://github.com/agronholm/anyio/pull/429
|
|
29
|
-
#
|
|
29
|
+
# Released in AnyIO 4.x.x
|
|
30
|
+
# The new function is anyio._core._eventloop.get_async_backend but that returns a
|
|
31
|
+
# class, not a module to extract the TaskGroup class from.
|
|
30
32
|
def get_asynclib(asynclib_name: Union[str, None] = None) -> Any:
|
|
31
33
|
if asynclib_name is None:
|
|
32
34
|
asynclib_name = sniffio.current_async_library()
|
|
@@ -298,7 +300,12 @@ def syncify(
|
|
|
298
300
|
|
|
299
301
|
@functools.wraps(async_function)
|
|
300
302
|
def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
|
|
301
|
-
current_async_module =
|
|
303
|
+
current_async_module = (
|
|
304
|
+
getattr(threadlocals, "current_async_backend", None)
|
|
305
|
+
or
|
|
306
|
+
# TODO: remove when deprecating AnyIO 3.x
|
|
307
|
+
getattr(threadlocals, "current_async_module", None)
|
|
308
|
+
)
|
|
302
309
|
partial_f = functools.partial(async_function, *args, **kwargs)
|
|
303
310
|
if current_async_module is None and raise_sync_error is False:
|
|
304
311
|
return anyio.run(partial_f)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import anyio
|
|
4
|
+
from asyncer import asyncify
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def do_sync_work(name: str):
|
|
8
|
+
time.sleep(1)
|
|
9
|
+
return f"Hello, {name}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
async def main():
|
|
13
|
+
message = await asyncify(do_sync_work)(name="World")
|
|
14
|
+
print(message)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
anyio.run(main)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
import asyncer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def do_work(name: str):
|
|
6
|
+
await anyio.sleep(1)
|
|
7
|
+
return f"Hello, {name}"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async def main(name: str):
|
|
11
|
+
result = await do_work(name=name)
|
|
12
|
+
return result
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
result = asyncer.runnify(main)(name="World")
|
|
16
|
+
print(result)
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
async def do_work(name: str):
|
|
5
|
+
await anyio.sleep(1)
|
|
6
|
+
print(f"Hello, {name}")
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def get_data():
|
|
10
|
+
await do_work(name="Yury")
|
|
11
|
+
await do_work(name="Nathaniel")
|
|
12
|
+
await do_work(name="Alex")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async def main():
|
|
16
|
+
await get_data()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
anyio.run(main)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
import asyncer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def do_work(name: str):
|
|
6
|
+
await anyio.sleep(1)
|
|
7
|
+
print(f"Hello, {name}")
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async def get_data():
|
|
11
|
+
async with asyncer.create_task_group() as task_group:
|
|
12
|
+
task_group.soonify(do_work)(name="Yury")
|
|
13
|
+
task_group.soonify(do_work)(name="Nathaniel")
|
|
14
|
+
task_group.soonify(do_work)(name="Alex")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async def main():
|
|
18
|
+
await get_data()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
anyio.run(main)
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
import asyncer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def do_work(name: str):
|
|
6
|
+
await anyio.sleep(1)
|
|
7
|
+
message = f"Hello, {name}"
|
|
8
|
+
return message
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def get_data():
|
|
12
|
+
async with asyncer.create_task_group() as task_group:
|
|
13
|
+
soon_value1 = task_group.soonify(do_work)(name="Yury")
|
|
14
|
+
soon_value2 = task_group.soonify(do_work)(name="Nathaniel")
|
|
15
|
+
soon_value3 = task_group.soonify(do_work)(name="Alex")
|
|
16
|
+
|
|
17
|
+
data = [soon_value1.value, soon_value2.value, soon_value3.value]
|
|
18
|
+
return data
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
async def main():
|
|
22
|
+
data = await get_data()
|
|
23
|
+
for message in data:
|
|
24
|
+
print(message)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
anyio.run(main)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
import asyncer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def do_work(name: str):
|
|
6
|
+
await anyio.sleep(1)
|
|
7
|
+
message = f"Hello, {name}"
|
|
8
|
+
return message
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def get_data():
|
|
12
|
+
async with asyncer.create_task_group() as task_group:
|
|
13
|
+
soon_value1 = task_group.soonify(do_work)(name="Yury")
|
|
14
|
+
soon_value2 = task_group.soonify(do_work)(name="Nathaniel")
|
|
15
|
+
soon_value3 = task_group.soonify(do_work)(name="Alex")
|
|
16
|
+
print(soon_value1.value)
|
|
17
|
+
|
|
18
|
+
data = [soon_value1.value, soon_value2.value, soon_value3.value]
|
|
19
|
+
return data
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async def main():
|
|
23
|
+
data = await get_data()
|
|
24
|
+
for message in data:
|
|
25
|
+
print(message)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
anyio.run(main)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import anyio
|
|
2
|
+
import asyncer
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
async def do_work(name: str):
|
|
6
|
+
await anyio.sleep(1)
|
|
7
|
+
message = f"Hello, {name}"
|
|
8
|
+
return message
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def get_data():
|
|
12
|
+
async with asyncer.create_task_group() as task_group:
|
|
13
|
+
soon_value1 = task_group.soonify(do_work)(name="Yury")
|
|
14
|
+
await anyio.sleep(2)
|
|
15
|
+
if soon_value1.ready:
|
|
16
|
+
print(f"Preview value1: {soon_value1.value}")
|
|
17
|
+
soon_value2 = task_group.soonify(do_work)(name="Nathaniel")
|
|
18
|
+
soon_value3 = task_group.soonify(do_work)(name="Alex")
|
|
19
|
+
|
|
20
|
+
data = [soon_value1.value, soon_value2.value, soon_value3.value]
|
|
21
|
+
return data
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async def main():
|
|
25
|
+
data = await get_data()
|
|
26
|
+
for message in data:
|
|
27
|
+
print(message)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
anyio.run(main)
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import anyio
|
|
4
|
+
from asyncer import asyncify, syncify
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
async def do_async_work(name: str):
|
|
8
|
+
await anyio.sleep(1)
|
|
9
|
+
return f"Hello, {name}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def do_sync_work(name: str):
|
|
13
|
+
time.sleep(1)
|
|
14
|
+
message = syncify(do_async_work)(name=name)
|
|
15
|
+
return message
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def main():
|
|
19
|
+
message = await asyncify(do_sync_work)(name="World")
|
|
20
|
+
print(message)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
anyio.run(main)
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import anyio
|
|
4
|
+
from asyncer import asyncify, syncify
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
async def do_async_work(name: str):
|
|
8
|
+
await anyio.sleep(1)
|
|
9
|
+
return f"Hello, {name}"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def do_sync_work(name: str):
|
|
13
|
+
time.sleep(1)
|
|
14
|
+
message = syncify(do_async_work, raise_sync_error=False)(name=name)
|
|
15
|
+
return message
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
async def main():
|
|
19
|
+
message = await asyncify(do_sync_work)(name="World")
|
|
20
|
+
print(message)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def sync_main():
|
|
24
|
+
message = do_sync_work(name="Sync World")
|
|
25
|
+
print(message)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
anyio.run(main)
|
|
29
|
+
sync_main()
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"pdm-backend",
|
|
4
|
+
]
|
|
5
|
+
build-backend = "pdm.backend"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "asyncer"
|
|
9
|
+
dynamic = []
|
|
10
|
+
description = "Asyncer, async and await, focused on developer experience."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Sebastián Ramírez", email = "tiangolo@gmail.com" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Framework :: AsyncIO",
|
|
19
|
+
"Framework :: Trio",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Intended Audience :: Education",
|
|
22
|
+
"Intended Audience :: Information Technology",
|
|
23
|
+
"Intended Audience :: Science/Research",
|
|
24
|
+
"Intended Audience :: System Administrators",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
+
"Programming Language :: Python :: 3.8",
|
|
28
|
+
"Programming Language :: Python :: 3.9",
|
|
29
|
+
"Programming Language :: Python :: 3.10",
|
|
30
|
+
"Programming Language :: Python :: 3.11",
|
|
31
|
+
"Programming Language :: Python :: 3.12",
|
|
32
|
+
"Topic :: Internet",
|
|
33
|
+
"Typing :: Typed",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"anyio >=3.4.0,<5.0",
|
|
37
|
+
"typing_extensions >=4.8.0; python_version < '3.10'",
|
|
38
|
+
]
|
|
39
|
+
version = "0.0.6.dev1"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/tiangolo/asyncer"
|
|
43
|
+
Documentation = "https://asyncer.tiangolo.com"
|
|
44
|
+
Repository = "https://github.com/tiangolo/asyncer"
|
|
45
|
+
|
|
46
|
+
[tool.pdm]
|
|
47
|
+
distribution = true
|
|
48
|
+
|
|
49
|
+
[tool.pdm.version]
|
|
50
|
+
source = "file"
|
|
51
|
+
path = "asyncer/__init__.py"
|
|
52
|
+
|
|
53
|
+
[tool.pdm.build]
|
|
54
|
+
source-includes = [
|
|
55
|
+
"tests/",
|
|
56
|
+
"docs_src/",
|
|
57
|
+
"requirements*.txt",
|
|
58
|
+
"scripts/",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[tool.coverage.run]
|
|
62
|
+
parallel = true
|
|
63
|
+
source = [
|
|
64
|
+
"docs_src",
|
|
65
|
+
"tests",
|
|
66
|
+
"asyncer",
|
|
67
|
+
]
|
|
68
|
+
context = "${CONTEXT}"
|
|
69
|
+
|
|
70
|
+
[tool.coverage.report]
|
|
71
|
+
omit = [
|
|
72
|
+
"docs_src/tutorial/soonify_return/tutorial002.py",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
strict = true
|
|
77
|
+
|
|
78
|
+
[[tool.mypy.overrides]]
|
|
79
|
+
module = "docs_src.*"
|
|
80
|
+
disallow_incomplete_defs = false
|
|
81
|
+
disallow_untyped_defs = false
|
|
82
|
+
disallow_untyped_calls = false
|
|
83
|
+
warn_no_return = false
|
|
84
|
+
|
|
85
|
+
[tool.ruff.lint]
|
|
86
|
+
select = [
|
|
87
|
+
"E",
|
|
88
|
+
"W",
|
|
89
|
+
"F",
|
|
90
|
+
"I",
|
|
91
|
+
"B",
|
|
92
|
+
"C4",
|
|
93
|
+
"UP",
|
|
94
|
+
]
|
|
95
|
+
ignore = [
|
|
96
|
+
"E501",
|
|
97
|
+
"B008",
|
|
98
|
+
"C901",
|
|
99
|
+
"W191",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.ruff.lint.per-file-ignores]
|
|
103
|
+
|
|
104
|
+
[tool.ruff.lint.isort]
|
|
105
|
+
known-third-party = [
|
|
106
|
+
"asyncer",
|
|
107
|
+
"anyio",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
[tool.ruff.lint.pyupgrade]
|
|
111
|
+
keep-runtime-typing = true
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
-e .
|
|
2
|
+
|
|
3
|
+
mkdocs-material==9.4.7
|
|
4
|
+
mdx-include >=1.4.1,<2.0.0
|
|
5
|
+
mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
|
|
6
|
+
mkdocs-redirects>=1.2.1,<1.3.0
|
|
7
|
+
pyyaml >=5.3.1,<7.0.0
|
|
8
|
+
# For Material for MkDocs, Chinese search
|
|
9
|
+
jieba==0.42.1
|
|
10
|
+
# For image processing by Material for MkDocs
|
|
11
|
+
pillow==10.1.0
|
|
12
|
+
# For image processing by Material for MkDocs
|
|
13
|
+
cairosvg==2.7.0
|
|
14
|
+
mkdocstrings[python]==0.23.0
|
|
15
|
+
griffe-typingdoc==0.2.2
|
|
16
|
+
# For griffe, it formats with black
|
|
17
|
+
black==23.3.0
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from typing import Any, Callable, Dict, List, Union
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def get_testing_print_function(
|
|
5
|
+
calls: List[List[Union[str, Dict[str, Any]]]],
|
|
6
|
+
) -> Callable[..., Any]:
|
|
7
|
+
def new_print(*args):
|
|
8
|
+
data = []
|
|
9
|
+
for arg in args:
|
|
10
|
+
data.append(arg)
|
|
11
|
+
calls.append(data)
|
|
12
|
+
|
|
13
|
+
return new_print
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import List
|
|
4
|
+
|
|
5
|
+
import anyio
|
|
6
|
+
from asyncer import asyncify, syncify
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class Report:
|
|
11
|
+
thread_id: int
|
|
12
|
+
caller_func: str
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_syncify_no_raise_async():
|
|
16
|
+
reports: List[Report] = []
|
|
17
|
+
|
|
18
|
+
async def do_sub_async_work():
|
|
19
|
+
report = Report(
|
|
20
|
+
thread_id=threading.get_ident(),
|
|
21
|
+
caller_func="do_sub_async_work",
|
|
22
|
+
)
|
|
23
|
+
reports.append(report)
|
|
24
|
+
|
|
25
|
+
def do_sub_sync_work():
|
|
26
|
+
report = Report(
|
|
27
|
+
thread_id=threading.get_ident(),
|
|
28
|
+
caller_func="do_sub_sync_work",
|
|
29
|
+
)
|
|
30
|
+
reports.append(report)
|
|
31
|
+
syncify(do_sub_async_work, raise_sync_error=False)()
|
|
32
|
+
|
|
33
|
+
async def do_async_work():
|
|
34
|
+
report = Report(
|
|
35
|
+
thread_id=threading.get_ident(),
|
|
36
|
+
caller_func="do_async_work",
|
|
37
|
+
)
|
|
38
|
+
reports.append(report)
|
|
39
|
+
await asyncify(do_sub_sync_work)()
|
|
40
|
+
|
|
41
|
+
def do_sync_work():
|
|
42
|
+
own_report = Report(
|
|
43
|
+
thread_id=threading.get_ident(),
|
|
44
|
+
caller_func="do_sync_work",
|
|
45
|
+
)
|
|
46
|
+
reports.append(own_report)
|
|
47
|
+
syncify(do_async_work, raise_sync_error=False)()
|
|
48
|
+
|
|
49
|
+
async def main():
|
|
50
|
+
own_report = Report(
|
|
51
|
+
thread_id=threading.get_ident(),
|
|
52
|
+
caller_func="main",
|
|
53
|
+
)
|
|
54
|
+
reports.append(own_report)
|
|
55
|
+
await asyncify(do_sync_work)()
|
|
56
|
+
|
|
57
|
+
def sync_main():
|
|
58
|
+
own_report = Report(
|
|
59
|
+
thread_id=threading.get_ident(),
|
|
60
|
+
caller_func="sync_main",
|
|
61
|
+
)
|
|
62
|
+
reports.append(own_report)
|
|
63
|
+
do_sync_work()
|
|
64
|
+
|
|
65
|
+
anyio.run(main)
|
|
66
|
+
sync_main()
|
|
67
|
+
main_thread_id = threading.get_ident()
|
|
68
|
+
assert reports[0].caller_func == "main"
|
|
69
|
+
assert reports[0].thread_id == main_thread_id
|
|
70
|
+
assert reports[1].caller_func == "do_sync_work"
|
|
71
|
+
assert reports[1].thread_id != main_thread_id
|
|
72
|
+
assert reports[2].caller_func == "do_async_work"
|
|
73
|
+
assert reports[2].thread_id == main_thread_id
|
|
74
|
+
assert reports[3].caller_func == "do_sub_sync_work"
|
|
75
|
+
assert reports[3].thread_id != main_thread_id
|
|
76
|
+
assert reports[4].caller_func == "do_sub_async_work"
|
|
77
|
+
assert reports[4].thread_id == main_thread_id
|
|
78
|
+
assert reports[5].caller_func == "sync_main"
|
|
79
|
+
assert reports[5].thread_id == main_thread_id
|
|
80
|
+
assert reports[6].caller_func == "do_sync_work"
|
|
81
|
+
assert reports[6].thread_id == main_thread_id
|
|
82
|
+
assert reports[7].caller_func == "do_async_work"
|
|
83
|
+
assert reports[7].thread_id == main_thread_id
|
|
84
|
+
assert reports[8].caller_func == "do_sub_sync_work"
|
|
85
|
+
assert reports[8].thread_id != main_thread_id
|
|
86
|
+
assert reports[9].caller_func == "do_sub_async_work"
|
|
87
|
+
assert reports[9].thread_id == main_thread_id
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.asyncify import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"]]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.asyncify import tutorial002 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"]]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial_001():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.first_steps import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"]]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial_001():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.runnify import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"]]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.soonify import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, Yury"], ["Hello, Nathaniel"], ["Hello, Alex"]]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.soonify import tutorial002 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, Yury"], ["Hello, Nathaniel"], ["Hello, Alex"]]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.soonify_return import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, Yury"], ["Hello, Nathaniel"], ["Hello, Alex"]]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
from unittest.mock import patch
|
|
3
|
+
|
|
4
|
+
import asyncer
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
if sys.version_info < (3, 11):
|
|
8
|
+
from exceptiongroup import ExceptionGroup
|
|
9
|
+
|
|
10
|
+
from ...conftest import get_testing_print_function
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_tutorial():
|
|
14
|
+
calls = []
|
|
15
|
+
|
|
16
|
+
new_print = get_testing_print_function(calls)
|
|
17
|
+
|
|
18
|
+
with patch("builtins.print", new=new_print):
|
|
19
|
+
with pytest.raises((ExceptionGroup, asyncer.PendingValueException)) as e:
|
|
20
|
+
from docs_src.tutorial.soonify_return import tutorial002 as mod
|
|
21
|
+
|
|
22
|
+
# Avoid autoflake removing this import
|
|
23
|
+
assert mod # pragma: nocover
|
|
24
|
+
if isinstance(e.value, ExceptionGroup):
|
|
25
|
+
assert isinstance(e.value.exceptions[0], asyncer.PendingValueException)
|
|
26
|
+
else:
|
|
27
|
+
assert isinstance(e.value, asyncer.PendingValueException)
|
|
28
|
+
assert calls == []
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.soonify_return import tutorial003 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [
|
|
16
|
+
["Preview value1: Hello, Yury"],
|
|
17
|
+
["Hello, Yury"],
|
|
18
|
+
["Hello, Nathaniel"],
|
|
19
|
+
["Hello, Alex"],
|
|
20
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.syncify import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"]]
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from unittest.mock import patch
|
|
2
|
+
|
|
3
|
+
from ...conftest import get_testing_print_function
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_tutorial():
|
|
7
|
+
calls = []
|
|
8
|
+
|
|
9
|
+
new_print = get_testing_print_function(calls)
|
|
10
|
+
|
|
11
|
+
with patch("builtins.print", new=new_print):
|
|
12
|
+
from docs_src.tutorial.syncify_no_raise import tutorial001 as mod
|
|
13
|
+
|
|
14
|
+
assert mod
|
|
15
|
+
assert calls == [["Hello, World"], ["Hello, Sync World"]]
|
asyncer-0.0.4/pyproject.toml
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
[tool.poetry]
|
|
2
|
-
name = "asyncer"
|
|
3
|
-
version = "0"
|
|
4
|
-
description = "Asyncer, async and await, focused on developer experience."
|
|
5
|
-
authors = ["Sebastián Ramírez <tiangolo@gmail.com>"]
|
|
6
|
-
readme = "README.md"
|
|
7
|
-
homepage = "https://github.com/tiangolo/asyncer"
|
|
8
|
-
documentation = "https://asyncer.tiangolo.com"
|
|
9
|
-
repository = "https://github.com/tiangolo/asyncer"
|
|
10
|
-
license = "MIT"
|
|
11
|
-
classifiers = [
|
|
12
|
-
"Development Status :: 4 - Beta",
|
|
13
|
-
"Framework :: AsyncIO",
|
|
14
|
-
"Framework :: Trio",
|
|
15
|
-
"Intended Audience :: Developers",
|
|
16
|
-
"Intended Audience :: Education",
|
|
17
|
-
"Intended Audience :: Information Technology",
|
|
18
|
-
"Intended Audience :: Science/Research",
|
|
19
|
-
"Intended Audience :: System Administrators",
|
|
20
|
-
"License :: OSI Approved :: MIT License",
|
|
21
|
-
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
-
"Programming Language :: Python :: 3.8",
|
|
23
|
-
"Programming Language :: Python :: 3.9",
|
|
24
|
-
"Programming Language :: Python :: 3.10",
|
|
25
|
-
"Programming Language :: Python :: 3.11",
|
|
26
|
-
"Programming Language :: Python :: 3.12",
|
|
27
|
-
"Topic :: Internet",
|
|
28
|
-
"Typing :: Typed",
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
[tool.poetry.dependencies]
|
|
32
|
-
python = "^3.8"
|
|
33
|
-
anyio = ">=3.4.0,<5.0"
|
|
34
|
-
typing_extensions = { version = "^4.8.0", python = "<3.10" }
|
|
35
|
-
|
|
36
|
-
[tool.poetry.dev-dependencies]
|
|
37
|
-
pytest = "^7.0.1"
|
|
38
|
-
mypy = "1.4.1"
|
|
39
|
-
mkdocs-material = "9.2.7"
|
|
40
|
-
pillow = "^9.3.0"
|
|
41
|
-
cairosvg = "^2.5.2"
|
|
42
|
-
mdx-include = "^1.4.1"
|
|
43
|
-
coverage = {extras = ["toml"], version = ">=6.2,<8.0"}
|
|
44
|
-
ruff = "^0.1.2"
|
|
45
|
-
|
|
46
|
-
[build-system]
|
|
47
|
-
requires = ["poetry-core"]
|
|
48
|
-
build-backend = "poetry.core.masonry.api"
|
|
49
|
-
|
|
50
|
-
[tool.poetry-version-plugin]
|
|
51
|
-
source = "init"
|
|
52
|
-
|
|
53
|
-
[tool.coverage.run]
|
|
54
|
-
parallel = true
|
|
55
|
-
source = [
|
|
56
|
-
"docs_src",
|
|
57
|
-
"tests",
|
|
58
|
-
"asyncer"
|
|
59
|
-
]
|
|
60
|
-
context = '${CONTEXT}'
|
|
61
|
-
|
|
62
|
-
[tool.coverage.report]
|
|
63
|
-
omit = [
|
|
64
|
-
"docs_src/tutorial/soonify_return/tutorial002.py",
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
[tool.mypy]
|
|
68
|
-
strict = true
|
|
69
|
-
|
|
70
|
-
[[tool.mypy.overrides]]
|
|
71
|
-
module = "docs_src.*"
|
|
72
|
-
disallow_incomplete_defs = false
|
|
73
|
-
disallow_untyped_defs = false
|
|
74
|
-
disallow_untyped_calls = false
|
|
75
|
-
warn_no_return = false
|
|
76
|
-
|
|
77
|
-
[tool.ruff]
|
|
78
|
-
select = [
|
|
79
|
-
"E", # pycodestyle errors
|
|
80
|
-
"W", # pycodestyle warnings
|
|
81
|
-
"F", # pyflakes
|
|
82
|
-
"I", # isort
|
|
83
|
-
"B", # flake8-bugbear
|
|
84
|
-
"C4", # flake8-comprehensions
|
|
85
|
-
"UP", # pyupgrade
|
|
86
|
-
]
|
|
87
|
-
ignore = [
|
|
88
|
-
"E501", # line too long, handled by black
|
|
89
|
-
"B008", # do not perform function calls in argument defaults
|
|
90
|
-
"W191", # indentation contains tabs
|
|
91
|
-
]
|
|
92
|
-
|
|
93
|
-
[tool.ruff.per-file-ignores]
|
|
94
|
-
"__init__.py" = ["F401"]
|
|
95
|
-
|
|
96
|
-
[tool.ruff.isort]
|
|
97
|
-
known-third-party = ["asyncer", "anyio"]
|
|
98
|
-
|
|
99
|
-
[tool.ruff.pyupgrade]
|
|
100
|
-
# Preserve types, even if a file imports `from __future__ import annotations`.
|
|
101
|
-
keep-runtime-typing = true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|