python-extracontext 1.1.0__tar.gz → 1.2.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.
- {python_extracontext-1.1.0/python_extracontext.egg-info → python_extracontext-1.2.0}/PKG-INFO +11 -4
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/__init__.py +1 -1
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/base.py +2 -2
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/executor.py +14 -3
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/mapping.py +3 -2
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/pyproject.toml +24 -3
- {python_extracontext-1.1.0 → python_extracontext-1.2.0/python_extracontext.egg-info}/PKG-INFO +11 -4
- python_extracontext-1.2.0/python_extracontext.egg-info/requires.txt +12 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_executor.py +0 -2
- python_extracontext-1.1.0/python_extracontext.egg-info/requires.txt +0 -6
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/LICENSE +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/README.md +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/_future_task.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/contextlocal.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/extracontext/contextlocal_native.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/SOURCES.txt +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/dependency_links.txt +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/top_level.txt +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/setup.cfg +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_async.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_contextmanager.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_generators.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_mapping.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_pep550.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_plain.py +0 -0
- {python_extracontext-1.1.0 → python_extracontext-1.2.0}/tests/test_thread.py +0 -0
{python_extracontext-1.1.0/python_extracontext.egg-info → python_extracontext-1.2.0}/PKG-INFO
RENAMED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-extracontext
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Context Variable namespaces supporting generators, asyncio and multi-threading
|
|
5
5
|
Author: Joao S. O. Bueno
|
|
6
6
|
Project-URL: repository, https://github.com/jsbueno/extracontext
|
|
7
|
+
Project-URL: documentation, https://jsbueno.github.io/extracontext/
|
|
7
8
|
Classifier: Development Status :: 5 - Production/Stable
|
|
8
9
|
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
16
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
17
18
|
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
@@ -24,6 +25,12 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
24
25
|
Requires-Dist: black; extra == "dev"
|
|
25
26
|
Requires-Dist: pyflakes; extra == "dev"
|
|
26
27
|
Requires-Dist: pytest-coverage; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
|
|
29
|
+
Provides-Extra: docs
|
|
30
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
31
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
33
|
+
Dynamic: license-file
|
|
27
34
|
|
|
28
35
|
# Extracontext: Context Local Variables for everyone
|
|
29
36
|
|
|
@@ -31,11 +31,22 @@ class _CustomWorkItem(concurrent.futures.thread._WorkItem):
|
|
|
31
31
|
super().__init__(*args, **kwargs)
|
|
32
32
|
self._context = contextvars.copy_context()
|
|
33
33
|
|
|
34
|
-
def run(self):
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
def run(self, ctx=None):
|
|
35
|
+
context_vars_ctx = self._context.copy()
|
|
36
|
+
# Python 3.14: the signature for _WorkItem.run changed, and
|
|
37
|
+
# it now needs an intemediate object that is passed in the "ctx" parameter.
|
|
38
|
+
result = context_vars_ctx.run(super().run, *((ctx,) if ctx else () ))
|
|
37
39
|
return result
|
|
38
40
|
|
|
41
|
+
import sys
|
|
42
|
+
"""
|
|
43
|
+
There are some changes in Python 3.14 to copy the context of the original thread,
|
|
44
|
+
but it still won't work with a task-specific context
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
if sys.version_info >= (3,14):
|
|
48
|
+
pass
|
|
49
|
+
|
|
39
50
|
|
|
40
51
|
original_submit = ThreadPoolExecutor.submit
|
|
41
52
|
new_globals = concurrent.futures.thread.__dict__.copy()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from collections.abc import Mapping, MutableMapping
|
|
2
|
+
from typing import Optional
|
|
2
3
|
|
|
3
4
|
from .base import ContextLocal
|
|
4
5
|
from .contextlocal import PyContextLocal
|
|
@@ -48,7 +49,7 @@ class PyContextMap(ContextMap, PyContextLocal):
|
|
|
48
49
|
_backend_key = "python"
|
|
49
50
|
_BASEDIST = 1
|
|
50
51
|
|
|
51
|
-
def __init__(self, initial:
|
|
52
|
+
def __init__(self, initial: Optional[Mapping] = None, *, backend=None):
|
|
52
53
|
super().__init__()
|
|
53
54
|
if not initial:
|
|
54
55
|
return
|
|
@@ -63,7 +64,7 @@ class PyContextMap(ContextMap, PyContextLocal):
|
|
|
63
64
|
class NativeContextMap(ContextMap, NativeContextLocal):
|
|
64
65
|
_backend_key = "native"
|
|
65
66
|
|
|
66
|
-
def __init__(self, initial:
|
|
67
|
+
def __init__(self, initial: Optional[Mapping] = None, *, backend=None):
|
|
67
68
|
super().__init__()
|
|
68
69
|
if not initial:
|
|
69
70
|
return
|
|
@@ -19,20 +19,23 @@ authors = [{ name = "Joao S. O. Bueno" }]
|
|
|
19
19
|
classifiers = [
|
|
20
20
|
"Development Status :: 5 - Production/Stable",
|
|
21
21
|
"Intended Audience :: Developers",
|
|
22
|
-
"Programming Language :: Python :: 3.8",
|
|
23
|
-
"Programming Language :: Python :: 3.9",
|
|
24
22
|
"Programming Language :: Python :: 3.10",
|
|
25
23
|
"Programming Language :: Python :: 3.11",
|
|
26
24
|
"Programming Language :: Python :: 3.12",
|
|
27
25
|
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Programming Language :: Python :: 3.15",
|
|
28
28
|
"Programming Language :: Python :: Implementation :: CPython",
|
|
29
29
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
30
30
|
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
|
|
31
31
|
"Operating System :: OS Independent",
|
|
32
32
|
]
|
|
33
|
+
dependencies = [
|
|
34
|
+
]
|
|
33
35
|
|
|
34
36
|
[project.urls]
|
|
35
37
|
repository = "https://github.com/jsbueno/extracontext"
|
|
38
|
+
documentation = "https://jsbueno.github.io/extracontext/"
|
|
36
39
|
|
|
37
40
|
|
|
38
41
|
[project.optional-dependencies]
|
|
@@ -41,13 +44,31 @@ dev = [
|
|
|
41
44
|
"black",
|
|
42
45
|
"pyflakes",
|
|
43
46
|
"pytest-coverage",
|
|
47
|
+
"pytest-timeout>=2.4.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
docs = [
|
|
51
|
+
"mkdocs",
|
|
52
|
+
"mkdocs-material",
|
|
53
|
+
"mkdocstrings[python]",
|
|
44
54
|
]
|
|
45
55
|
|
|
46
56
|
[tool.pytest.ini_options]
|
|
57
|
+
timeout = 2
|
|
47
58
|
testpaths = "tests"
|
|
48
59
|
python_files = "test_*.py"
|
|
49
60
|
python_functions = "test_*"
|
|
50
|
-
addopts = "-v --doctest-modules"
|
|
61
|
+
addopts = "-v --doctest-modules"
|
|
62
|
+
|
|
63
|
+
[tool.tox]
|
|
64
|
+
legacy_tox_ini = """
|
|
65
|
+
[tox]
|
|
66
|
+
env_list = py310, py311, py312, py313, py314, pypy310, pypy311, py313t, py314t
|
|
67
|
+
|
|
68
|
+
[testenv]
|
|
69
|
+
extras = dev
|
|
70
|
+
commands = pytest
|
|
71
|
+
"""
|
|
51
72
|
|
|
52
73
|
[tool.mypy]
|
|
53
74
|
mypy_path = "typecheck"
|
{python_extracontext-1.1.0 → python_extracontext-1.2.0/python_extracontext.egg-info}/PKG-INFO
RENAMED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-extracontext
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: Context Variable namespaces supporting generators, asyncio and multi-threading
|
|
5
5
|
Author: Joao S. O. Bueno
|
|
6
6
|
Project-URL: repository, https://github.com/jsbueno/extracontext
|
|
7
|
+
Project-URL: documentation, https://jsbueno.github.io/extracontext/
|
|
7
8
|
Classifier: Development Status :: 5 - Production/Stable
|
|
8
9
|
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
12
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
16
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
16
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
17
18
|
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
@@ -24,6 +25,12 @@ Requires-Dist: pytest; extra == "dev"
|
|
|
24
25
|
Requires-Dist: black; extra == "dev"
|
|
25
26
|
Requires-Dist: pyflakes; extra == "dev"
|
|
26
27
|
Requires-Dist: pytest-coverage; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-timeout>=2.4.0; extra == "dev"
|
|
29
|
+
Provides-Extra: docs
|
|
30
|
+
Requires-Dist: mkdocs; extra == "docs"
|
|
31
|
+
Requires-Dist: mkdocs-material; extra == "docs"
|
|
32
|
+
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
33
|
+
Dynamic: license-file
|
|
27
34
|
|
|
28
35
|
# Extracontext: Context Local Variables for everyone
|
|
29
36
|
|
|
@@ -9,7 +9,6 @@ from extracontext import ContextPreservingExecutor, ContextLocal
|
|
|
9
9
|
|
|
10
10
|
def test_executor_preserves_context():
|
|
11
11
|
# test executed using ordinary contexts
|
|
12
|
-
|
|
13
12
|
executor = ContextPreservingExecutor(1)
|
|
14
13
|
|
|
15
14
|
myvar = None
|
|
@@ -24,7 +23,6 @@ def test_executor_preserves_context():
|
|
|
24
23
|
|
|
25
24
|
async def stage_2():
|
|
26
25
|
nonlocal all_ok, message # myvar
|
|
27
|
-
|
|
28
26
|
myvar.set(23)
|
|
29
27
|
loop = asyncio.get_running_loop()
|
|
30
28
|
task1 = loop.run_in_executor(executor, stage_3)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python_extracontext-1.1.0 → python_extracontext-1.2.0}/python_extracontext.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|