Compare commits

...

3 Commits

Author SHA1 Message Date
Tyler Goodlet 8a83a68e3e Right, use `pytest>=3.8.5` with `--dev` flag to `uv` 2025-03-19 14:23:40 -04:00
Tyler Goodlet e885a18b0c 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-19 13:30:07 -04:00
Tyler Goodlet 466c68896e Bump up to `pytest>=3.8.5` to match "GH actions" 2025-03-19 10:02:05 -04:00
3 changed files with 27 additions and 10 deletions

View File

@ -57,7 +57,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>=3.8.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

@ -390,7 +390,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 = ">=3.8.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" },
] ]