universalasync 0.3.1.2__tar.gz → 0.4.0.0__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.
Files changed (40) hide show
  1. universalasync-0.4.0.0/.circleci/config.yml +124 -0
  2. universalasync-0.4.0.0/.editorconfig +20 -0
  3. universalasync-0.4.0.0/.gitignore +16 -0
  4. universalasync-0.4.0.0/.pre-commit-config.yaml +39 -0
  5. universalasync-0.4.0.0/.readthedocs.yaml +17 -0
  6. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/CHANGELOG.md +8 -0
  7. universalasync-0.4.0.0/Makefile +17 -0
  8. {universalasync-0.3.1.2/universalasync.egg-info → universalasync-0.4.0.0}/PKG-INFO +13 -12
  9. universalasync-0.4.0.0/docs/Makefile +20 -0
  10. universalasync-0.4.0.0/docs/api.rst +7 -0
  11. universalasync-0.4.0.0/docs/conf.py +64 -0
  12. universalasync-0.4.0.0/docs/index.rst +88 -0
  13. universalasync-0.4.0.0/docs/make.bat +35 -0
  14. universalasync-0.4.0.0/docs/requirements.txt +6 -0
  15. universalasync-0.4.0.0/pyproject.toml +88 -0
  16. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/test_asyncgen.py +2 -2
  17. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/test_usage.py +9 -7
  18. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/test_utils.py +12 -10
  19. universalasync-0.4.0.0/universalasync/utils.py +17 -0
  20. universalasync-0.4.0.0/universalasync/version.py +1 -0
  21. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/universalasync/wrapper.py +6 -5
  22. universalasync-0.4.0.0/uv.lock +434 -0
  23. universalasync-0.3.1.2/PKG-INFO +0 -108
  24. universalasync-0.3.1.2/pyproject.toml +0 -39
  25. universalasync-0.3.1.2/setup.cfg +0 -4
  26. universalasync-0.3.1.2/setup.py +0 -39
  27. universalasync-0.3.1.2/universalasync/utils.py +0 -28
  28. universalasync-0.3.1.2/universalasync/version.py +0 -1
  29. universalasync-0.3.1.2/universalasync.egg-info/SOURCES.txt +0 -22
  30. universalasync-0.3.1.2/universalasync.egg-info/dependency_links.txt +0 -1
  31. universalasync-0.3.1.2/universalasync.egg-info/top_level.txt +0 -1
  32. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/LICENSE +0 -0
  33. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/MANIFEST.in +0 -0
  34. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/README.md +0 -0
  35. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/__init__.py +0 -0
  36. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/conftest.py +0 -0
  37. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/test_basic.py +0 -0
  38. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/tests/utils.py +0 -0
  39. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/universalasync/__init__.py +0 -0
  40. {universalasync-0.3.1.2 → universalasync-0.4.0.0}/universalasync/py.typed +0 -0
@@ -0,0 +1,124 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ bitcart: bitcart/bitcart-shared@2
5
+
6
+ executors:
7
+ main-executor:
8
+ parameters:
9
+ v:
10
+ type: string
11
+ default: "3.9"
12
+
13
+ docker:
14
+ - image: cimg/python:<< parameters.v >>
15
+
16
+ environment:
17
+ TEST_ARGS: "--junitxml test-results/pytest/coverage.xml --cov-report html:coverage"
18
+
19
+ commands:
20
+ install_dependencies:
21
+ parameters:
22
+ cache_dir:
23
+ type: string
24
+ default: /home/circleci/.cache/uv
25
+
26
+ steps:
27
+ - restore_cache:
28
+ keys:
29
+ - v1-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "uv.lock" }}
30
+
31
+ - run:
32
+ name: Install library
33
+ command: |
34
+ curl -LsSf https://astral.sh/uv/install.sh | sh
35
+ mkdir -p "<<parameters.cache_dir>>" && \
36
+ uv sync --frozen --compile-bytecode --cache-dir <<parameters.cache_dir>>
37
+ uv cache prune --ci --cache-dir <<parameters.cache_dir>>
38
+ echo ". ~/repo/.venv/bin/activate" >> $BASH_ENV
39
+
40
+ - save_cache:
41
+ paths:
42
+ - "<<parameters.cache_dir>>"
43
+ key: v1-dependencies-{{ .Branch }}-{{ checksum "~/.pyenv/version" }}-{{ checksum "uv.lock" }}
44
+
45
+ upload-results:
46
+ steps:
47
+ - store_test_results:
48
+ path: test-results
49
+
50
+ - store_artifacts:
51
+ path: coverage
52
+
53
+ - store_artifacts:
54
+ path: test-results
55
+
56
+ jobs:
57
+ test:
58
+ parameters:
59
+ v:
60
+ type: string
61
+
62
+ executor:
63
+ name: main-executor
64
+ v: << parameters.v >>
65
+
66
+ environment:
67
+ PYTHON: << parameters.v >>
68
+
69
+ working_directory: ~/repo
70
+
71
+ steps:
72
+ - checkout
73
+
74
+ - install_dependencies
75
+
76
+ - run:
77
+ name: run fast tests
78
+ command: |
79
+ make ci
80
+
81
+ - bitcart/codecov
82
+
83
+ - upload-results
84
+
85
+ deploy:
86
+ executor: bitcart/docker-python
87
+ docker:
88
+ - image: cimg/python:3.8
89
+ steps:
90
+ - checkout
91
+
92
+ - run:
93
+ name: upload package
94
+ command: |
95
+ curl -LsSf https://astral.sh/uv/install.sh | sh
96
+ uv build
97
+ uv publish --token $PYPI_TOKEN
98
+
99
+ workflows:
100
+ version: 2
101
+ test_and_deploy:
102
+ jobs:
103
+ - bitcart/lint:
104
+ name: lint
105
+ - test:
106
+ name: test-<< matrix.v >>
107
+ requires:
108
+ - lint
109
+ matrix:
110
+ parameters:
111
+ v:
112
+ - "3.9"
113
+ - "3.10"
114
+ - "3.11"
115
+ - "3.12"
116
+ - "3.13"
117
+
118
+ - deploy:
119
+ context: global
120
+ filters:
121
+ tags:
122
+ only: /[0-9]+(\.[0-9]+)*/
123
+ branches:
124
+ ignore: /.*/
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 4
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [Makefile]
13
+ indent_style = tab
14
+
15
+ [*.{yml,yaml}]
16
+ indent_size = 2
17
+
18
+ [*.md]
19
+ indent_size = 2
20
+ trim_trailing_whitespace = false
@@ -0,0 +1,16 @@
1
+ *.egg-info/
2
+ .coverage
3
+ .coverage.*
4
+ .idea/
5
+ .mypy_cache/
6
+ .prettiercache
7
+ .vscode/
8
+ __pycache__/
9
+ backup/
10
+ backups/
11
+ build/
12
+ dist/
13
+ docs/_build
14
+ env/
15
+ htmlcov/
16
+ venv/
@@ -0,0 +1,39 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-merge-conflict
6
+ - repo: https://github.com/asottile/yesqa
7
+ rev: v1.5.0
8
+ hooks:
9
+ - id: yesqa
10
+ - repo: https://github.com/astral-sh/ruff-pre-commit
11
+ rev: v0.8.3
12
+ hooks:
13
+ - id: ruff
14
+ - id: ruff-format
15
+ - repo: https://github.com/pre-commit/pre-commit-hooks
16
+ rev: v5.0.0
17
+ hooks:
18
+ - id: end-of-file-fixer
19
+ - id: trailing-whitespace
20
+ - id: mixed-line-ending
21
+ - id: file-contents-sorter
22
+ files: |
23
+ .gitignore|
24
+ - id: requirements-txt-fixer
25
+ - id: check-case-conflict
26
+ - id: check-shebang-scripts-are-executable
27
+ - id: check-json
28
+ - id: check-toml
29
+ - id: check-yaml
30
+ - id: check-symlinks
31
+ - id: debug-statements
32
+ - id: fix-byte-order-marker
33
+ - id: detect-private-key
34
+ - repo: https://github.com/pre-commit/mirrors-prettier
35
+ rev: v4.0.0-alpha.8
36
+ hooks:
37
+ - id: prettier
38
+ require_serial: true
39
+ args: ["--cache-location=.prettiercache"]
@@ -0,0 +1,17 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-22.04
5
+ tools:
6
+ python: "3.8"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+
11
+ formats: all
12
+
13
+ python:
14
+ install:
15
+ - method: pip
16
+ path: .
17
+ - requirements: docs/requirements.txt
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Latest changes
4
4
 
5
+ # 0.4.0.0
6
+
7
+ Drop python 3.8 support
8
+
9
+ Use ruff & uv as tooling
10
+
11
+ Support up to python 3.13
12
+
5
13
  ## 0.3.1.2
6
14
 
7
15
  Drop python 3.7 support
@@ -0,0 +1,17 @@
1
+ all: ci
2
+
3
+ lint:
4
+ ruff check
5
+ mypy universalasync
6
+
7
+ checkformat:
8
+ ruff format --check
9
+
10
+ format:
11
+ ruff format
12
+
13
+ test:
14
+ pytest tests/ ${TEST_ARGS}
15
+ @coverage combine > /dev/null 2>&1 || true
16
+
17
+ ci: checkformat lint test
@@ -1,26 +1,27 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: universalasync
3
- Version: 0.3.1.2
3
+ Version: 0.4.0.0
4
4
  Summary: A library to help automate the creation of universal python libraries
5
- Home-page: https://github.com/bitcart/universalasync
6
- Author: MrNaif2018
7
- Author-email: chuff184@gmail.com
8
- License: MIT
9
- Keywords: async,await,bitcart,universal,sync,asyncio,asynctosync,synctoasync
5
+ Project-URL: Homepage, https://github.com/bitcart/universalasync
6
+ Project-URL: Source, https://github.com/bitcart/universalasync
7
+ Project-URL: Changelog, https://github.com/bitcart/universalasync/blob/master/CHANGELOG.md
8
+ Author-email: MrNaif2018 <chuff184@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: async,asyncio,asynctosync,await,bitcart,sync,synctoasync,universal
10
12
  Classifier: Development Status :: 5 - Production/Stable
11
13
  Classifier: Intended Audience :: Developers
12
- Classifier: Topic :: Software Development :: Libraries
13
- Classifier: Topic :: Utilities
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
18
17
  Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
20
19
  Classifier: Programming Language :: Python :: 3.12
21
- Requires-Python: >=3.8
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Topic :: Utilities
23
+ Requires-Python: >=3.9
22
24
  Description-Content-Type: text/markdown
23
- License-File: LICENSE
24
25
 
25
26
  # universalasync
26
27
 
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,7 @@
1
+ API Reference
2
+ =============
3
+
4
+ .. automodule:: universalasync
5
+ :members:
6
+ :show-inheritance:
7
+ :undoc-members:
@@ -0,0 +1,64 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # This file only contains a selection of the most common options. For a full
4
+ # list see the documentation:
5
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
6
+
7
+ # -- Path setup --------------------------------------------------------------
8
+
9
+ # If extensions (or modules to document with autodoc) are in another directory,
10
+ # add these directories to sys.path here. If the directory is relative to the
11
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
12
+ #
13
+ import os
14
+ import sys
15
+
16
+ import pkg_resources
17
+
18
+ sys.path.insert(0, os.path.abspath(".."))
19
+
20
+
21
+ # -- Project information -----------------------------------------------------
22
+
23
+ project = "universalasync"
24
+ copyright = "2021, MrNaif2018"
25
+ author = "MrNaif2018"
26
+
27
+ # The full version, including alpha/beta/rc tags
28
+ release = pkg_resources.get_distribution("universalasync").version
29
+
30
+
31
+ # -- General configuration ---------------------------------------------------
32
+
33
+ # Add any Sphinx extension module names here, as strings. They can be
34
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
35
+ # ones.
36
+ extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon"]
37
+
38
+ # Add any paths that contain templates here, relative to this directory.
39
+ templates_path = ["_templates"]
40
+
41
+ # List of patterns, relative to source directory, that match files and
42
+ # directories to ignore when looking for source files.
43
+ # This pattern also affects html_static_path and html_extra_path.
44
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
45
+
46
+ napoleon_use_rtype = False
47
+
48
+ # -- Options for HTML output -------------------------------------------------
49
+
50
+ # The theme to use for HTML and HTML Help pages. See the documentation for
51
+ # a list of builtin themes.
52
+ #
53
+ html_theme = "sphinx_rtd_theme"
54
+
55
+ html_theme_options = {
56
+ "collapse_navigation": True,
57
+ "sticky_navigation": True,
58
+ "logo_only": True,
59
+ "display_version": True,
60
+ "style_external_links": True,
61
+ }
62
+
63
+ # readthedocs
64
+ master_doc = "index"
@@ -0,0 +1,88 @@
1
+ .. universalasync documentation master file, created by
2
+ sphinx-quickstart on Sun Dec 19 21:37:48 2021.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ Welcome to universalasync's documentation!
7
+ ==========================================
8
+
9
+ .. toctree::
10
+ :maxdepth: 2
11
+ :caption: Contents:
12
+
13
+ api
14
+
15
+
16
+ A library to help automate the creation of universal python libraries
17
+
18
+ Overview
19
+ ========
20
+
21
+ Have you ever been frustrated that you need to maintain both sync and async versions of your library, even thought their code differs by just async and await?
22
+ You might have came up to rewriting your code before release or other unreliable solutions.
23
+
24
+ This library helps you to focus only on the main async implementation of your library: sync one will be created automatically
25
+
26
+ Via decorating all your public methods, the wrapped functions automatically detect different conditions and run the functions accordingly.
27
+
28
+ If user uses your library in async context, minimal overhead is added, it just returns the coroutine right away.
29
+
30
+ Otherwise the library calls the coroutine via various loop methods, like as if you did it manually.
31
+
32
+ There should be no issues at all, the only limitation is that signals and async subprocesses are supported only when running in the main thread.
33
+
34
+ Also note that when run from a different os thread, the library will create a new event loop there and run coroutines.
35
+
36
+ This means that you might need to adapt your code a bit in case you use some resources bound to a certain event loop (like ``aiohttp.ClientSession``).
37
+
38
+ You can see an example of how this could be solved `here <https://github.com/bitcart/bitcart-sdk/blob/4a425f80f62a0c90f8c5fa19ccb7e578590dcead/bitcart/providers/jsonrpcrequests.py#L51-L58>`_
39
+
40
+ Installation
41
+ ============
42
+
43
+ ``pip install universalasync``
44
+
45
+ .. _example:
46
+
47
+ Example of usage
48
+ ================
49
+
50
+
51
+ .. code-block:: python
52
+
53
+ # wrap needed methods one by one
54
+ class Client:
55
+ @async_to_sync_wraps
56
+ async def help():
57
+ ...
58
+
59
+ @async_to_sync_wraps
60
+ @property
61
+ async def async_property():
62
+ ...
63
+
64
+ # or wrap whole classes
65
+ @wrap
66
+ class Client:
67
+ async def help(self):
68
+ ...
69
+
70
+ @property
71
+ async def async_property():
72
+ ...
73
+
74
+ client = Client()
75
+
76
+ def sync_call():
77
+ client.help()
78
+ client.async_property
79
+
80
+ async def async_call():
81
+ await client.help()
82
+ await client.async_property
83
+
84
+ # works in all cases
85
+ sync_call()
86
+ asyncio.run(async_call())
87
+ threading.Thread(target=sync_call).start()
88
+ threading.Thread(target=asyncio.run, args=(async_call(),)).start()
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+
13
+ if "%1" == "" goto help
14
+
15
+ %SPHINXBUILD% >NUL 2>NUL
16
+ if errorlevel 9009 (
17
+ echo.
18
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19
+ echo.installed, then set the SPHINXBUILD environment variable to point
20
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
21
+ echo.may add the Sphinx directory to PATH.
22
+ echo.
23
+ echo.If you don't have Sphinx installed, grab it from
24
+ echo.https://www.sphinx-doc.org/
25
+ exit /b 1
26
+ )
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,6 @@
1
+ commonmark
2
+ mock
3
+ pillow
4
+ recommonmark
5
+ sphinx
6
+ sphinx-rtd-theme
@@ -0,0 +1,88 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "universalasync"
7
+ dynamic = ["version"]
8
+ description = "A library to help automate the creation of universal python libraries"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [{ name = "MrNaif2018", email = "chuff184@gmail.com" }]
12
+ requires-python = ">=3.9"
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "Topic :: Software Development :: Libraries",
17
+ "Topic :: Utilities",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ ]
26
+ keywords = [
27
+ "async",
28
+ "await",
29
+ "bitcart",
30
+ "universal",
31
+ "sync",
32
+ "asyncio",
33
+ "asynctosync",
34
+ "synctoasync",
35
+ ]
36
+ dependencies = []
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/bitcart/universalasync"
40
+ Source = "https://github.com/bitcart/universalasync"
41
+ Changelog = "https://github.com/bitcart/universalasync/blob/master/CHANGELOG.md"
42
+
43
+ [dependency-groups]
44
+ dev = ["pre-commit", "pytest", "pytest-cov", "ruff", "mypy"]
45
+
46
+ [tool.uv]
47
+ default-groups = ['dev']
48
+
49
+ [tool.hatch.version]
50
+ path = "universalasync/version.py"
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["universalasync"]
54
+
55
+ [tool.ruff]
56
+ target-version = "py39"
57
+ line-length = 127
58
+
59
+ [tool.ruff.lint]
60
+ extend-select = ["UP", "B"]
61
+
62
+ [tool.mypy]
63
+ warn_redundant_casts = true
64
+ warn_unused_ignores = true
65
+ disallow_untyped_calls = true
66
+ disallow_untyped_defs = true
67
+ check_untyped_defs = true
68
+ warn_return_any = true
69
+ no_implicit_optional = true
70
+ strict_optional = true
71
+ ignore_missing_imports = true
72
+
73
+ [tool.pytest.ini_options]
74
+ addopts = ["--cov=universalasync", "--cov-report", "term-missing"]
75
+ filterwarnings = [
76
+ "error::DeprecationWarning",
77
+ "error::PendingDeprecationWarning",
78
+ ]
79
+
80
+ [tool.coverage.run]
81
+ omit = [
82
+ "*__init__.py",
83
+ "tests/*",
84
+ "venv/*",
85
+ "env/*",
86
+ "universalasync/version.py",
87
+ "setup.py",
88
+ ]
@@ -4,11 +4,11 @@ from universalasync import get_event_loop
4
4
 
5
5
 
6
6
  def test_asyncgen(client):
7
- assert type(client.async_gen()) == GeneratorType
7
+ assert type(client.async_gen()) is GeneratorType
8
8
  assert list(client.async_gen()) == list(range(10))
9
9
 
10
10
  async def async_part():
11
- assert type(client.async_gen()) == AsyncGeneratorType
11
+ assert type(client.async_gen()) is AsyncGeneratorType
12
12
  assert [i async for i in client.async_gen()] == list(range(10))
13
13
 
14
14
  loop = get_event_loop()
@@ -72,6 +72,14 @@ async def async_work(client, called):
72
72
  called.value = await client.async_method() is True and isinstance(client.async_gen(), types.AsyncGeneratorType)
73
73
 
74
74
 
75
+ def run_in_process(func, called):
76
+ obj = SampleClass()
77
+ result = globals()[func](obj, called)
78
+ if func.startswith("async_"):
79
+ result = asyncio.run(result)
80
+ return result
81
+
82
+
75
83
  @pytest.mark.parametrize(
76
84
  "func",
77
85
  [
@@ -86,13 +94,7 @@ async def async_work(client, called):
86
94
  def test_async_to_sync_usage(func):
87
95
  called = multiprocessing.Value("b", False)
88
96
 
89
- def inner():
90
- obj = SampleClass()
91
- result = globals()[func](obj, called)
92
- if func.startswith("async_"):
93
- result = asyncio.run(result)
94
-
95
- process = multiprocessing.Process(target=inner)
97
+ process = multiprocessing.Process(target=run_in_process, args=(func, called))
96
98
  process.start()
97
99
  total = 0
98
100
  while not called.value: