Compare commits

...

2 Commits

Author SHA1 Message Date
Tyler Goodlet d97e426bca Continue supporting py3.11+
Apparently the only thing needing a guard was use of
`asyncio.Queue.shutdown()` and the paired `QueueShutDown` exception?

Cool.
2025-03-24 19:10:21 -04:00
Tyler Goodlet c69877ea6f Bump up to `pytest>=8.3.5` to match "GH actions"
Ensure it's only for the `--dev` optional deps.
2025-03-24 19:10:21 -04:00
3 changed files with 29 additions and 12 deletions

View File

@ -54,7 +54,7 @@ dev = [
# test suite # test suite
# TODO: maybe some of these layout choices? # TODO: maybe some of these layout choices?
# https://docs.pytest.org/en/8.0.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules # https://docs.pytest.org/en/8.0.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules
"pytest>=8.2.0,<9", "pytest>=8.3.5",
"pexpect>=4.9.0,<5", "pexpect>=4.9.0,<5",
# `tractor.devx` tooling # `tractor.devx` tooling
"greenback>=1.2.1,<2", "greenback>=1.2.1,<2",

View File

@ -23,12 +23,10 @@ import asyncio
from asyncio.exceptions import ( from asyncio.exceptions import (
CancelledError, CancelledError,
) )
from asyncio import (
QueueShutDown,
)
from contextlib import asynccontextmanager as acm from contextlib import asynccontextmanager as acm
from dataclasses import dataclass from dataclasses import dataclass
import inspect import inspect
import platform
import traceback import traceback
from typing import ( from typing import (
Any, Any,
@ -79,6 +77,20 @@ __all__ = [
'run_as_asyncio_guest', 'run_as_asyncio_guest',
] ]
if (_py_313 := (
('3', '13')
==
platform.python_version_tuple()[:-1]
)
):
# 3.13+ only.. lel.
# https://docs.python.org/3.13/library/asyncio-queue.html#asyncio.QueueShutDown
from asyncio import (
QueueShutDown,
)
else:
QueueShutDown = False
# TODO, generally speaking we can generalize this abstraction, a "SC linked # TODO, generally speaking we can generalize this abstraction, a "SC linked
# parent->child task pair", as the same "supervision scope primitive" # parent->child task pair", as the same "supervision scope primitive"
@ -575,7 +587,11 @@ def _run_asyncio_task(
# normally suppressed unless the trio.Task also errors # normally suppressed unless the trio.Task also errors
# #
# ?TODO, is this even needed (does it happen) now? # ?TODO, is this even needed (does it happen) now?
elif isinstance(aio_err, QueueShutDown): elif (
_py_313
and
isinstance(aio_err, QueueShutDown)
):
# import pdbp; pdbp.set_trace() # import pdbp; pdbp.set_trace()
trio_err = AsyncioTaskExited( trio_err = AsyncioTaskExited(
'Task exited before `trio` side' 'Task exited before `trio` side'
@ -955,8 +971,9 @@ async def translate_aio_errors(
# or an error, we ensure the aio-side gets signalled via # or an error, we ensure the aio-side gets signalled via
# an explicit exception and its `Queue` is shutdown. # an explicit exception and its `Queue` is shutdown.
if ya_trio_exited: if ya_trio_exited:
# raise `QueueShutDown` on next `Queue.get()` call on # XXX py3.13+ ONLY..
# aio side. # raise `QueueShutDown` on next `Queue.get/put()`
if _py_313:
chan._to_aio.shutdown() chan._to_aio.shutdown()
# pump this event-loop (well `Runner` but ya) # pump this event-loop (well `Runner` but ya)

View File

@ -264,7 +264,7 @@ wheels = [
[[package]] [[package]]
name = "pytest" name = "pytest"
version = "8.3.4" version = "8.3.5"
source = { registry = "https://pypi.org/simple" } source = { registry = "https://pypi.org/simple" }
dependencies = [ dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" }, { name = "colorama", marker = "sys_platform == 'win32'" },
@ -272,9 +272,9 @@ dependencies = [
{ name = "packaging" }, { name = "packaging" },
{ name = "pluggy" }, { name = "pluggy" },
] ]
sdist = { url = "https://files.pythonhosted.org/packages/05/35/30e0d83068951d90a01852cb1cef56e5d8a09d20c7f511634cc2f7e0372a/pytest-8.3.4.tar.gz", hash = "sha256:965370d062bce11e73868e0335abac31b4d3de0e82f4007408d242b4f8610761", size = 1445919 } sdist = { url = "https://files.pythonhosted.org/packages/ae/3c/c9d525a414d506893f0cd8a8d0de7706446213181570cdbd766691164e40/pytest-8.3.5.tar.gz", hash = "sha256:f4efe70cc14e511565ac476b57c279e12a855b11f48f212af1080ef2263d3845", size = 1450891 }
wheels = [ wheels = [
{ url = "https://files.pythonhosted.org/packages/11/92/76a1c94d3afee238333bc0a42b82935dd8f9cf8ce9e336ff87ee14d9e1cf/pytest-8.3.4-py3-none-any.whl", hash = "sha256:50e16d954148559c9a74109af1eaf0c945ba2d8f30f0a3d3335edde19788b6f6", size = 343083 }, { url = "https://files.pythonhosted.org/packages/30/3d/64ad57c803f1fa1e963a7946b6e0fea4a70df53c1a7fed304586539c2bac/pytest-8.3.5-py3-none-any.whl", hash = "sha256:c69214aa47deac29fad6c2a4f590b9c4a9fdb16a403176fe154b79c0b4d4d820", size = 343634 },
] ]
[[package]] [[package]]
@ -358,7 +358,7 @@ dev = [
{ name = "pexpect", specifier = ">=4.9.0,<5" }, { name = "pexpect", specifier = ">=4.9.0,<5" },
{ name = "prompt-toolkit", specifier = ">=3.0.50" }, { name = "prompt-toolkit", specifier = ">=3.0.50" },
{ name = "pyperclip", specifier = ">=1.9.0" }, { name = "pyperclip", specifier = ">=1.9.0" },
{ name = "pytest", specifier = ">=8.2.0,<9" }, { name = "pytest", specifier = ">=8.3.5" },
{ name = "stackscope", specifier = ">=0.2.2,<0.3" }, { name = "stackscope", specifier = ">=0.2.2,<0.3" },
{ name = "xonsh", specifier = ">=0.19.2" }, { name = "xonsh", specifier = ">=0.19.2" },
] ]