Comments (5)
For line number debugging purposes, which exact version of Trio are you using? For example, on my machine, I can do this to get the version:
>>> import trio
>>> trio.__version__
'0.26.0'
from trio.
Nevermind I misread this issue.
from trio.
0.22.2
from trio.
I've got this based off your minimal example:
from __future__ import annotations
import trio
from contextlib import asynccontextmanager, AbstractAsyncContextManager
from collections.abc import Callable, AsyncGenerator
from typing import TypeVar
T = TypeVar("T")
@asynccontextmanager
async def par_w(a: Callable[[], AbstractAsyncContextManager[T]]) -> AsyncGenerator[T, None]:
ca = a()
value = await ca.__aenter__()
yield value
await ca.__aexit__(None, None, None)
async def run() -> None:
context_manager = trio.open_nursery
async def do_three() -> None:
print("3 start")
await trio.sleep(1)
print("3 end")
async with par_w(context_manager) as nursery:
print("1")
await trio.sleep(1)
print("2")
nursery.start_soon(do_three)
print("end")
print("4")
if __name__ == "__main__":
trio.run(run)
and I don't see any errors happening, so I'm guessing it's an issue with whatever async context manager you are passing in as a
to your par_w
function. If you could share what that is that would be great.
from trio.
The issue here is similar to the async generator issue. Because you're calling with statement methods directly, you have to be incredibly careful to preserve the nesting order. Otherwise, Trio's internal cancel scope stack can get messed up, breaking everything.
It's probably best to avoid calling them directly, instead use ExitStack
, or put things in different tasks for concurrency.
from trio.
Related Issues (20)
- Remove (Deprecate??) TrioDeprecationWarning HOT 4
- > (my perspective is someone who uses Trio for concurrency uses and very much a networking noob!)
- open_nursery is unable to call move_on_after when it is active, but it can still work. HOT 2
- Remaining test issues with Python 3.13.0b1: not ki_protected, pathlib.Path.resolve siganture HOT 6
- Ctrl+C behavior problems at the new REPL HOT 7
- Would be to actually port aiomultiprocess to trio? HOT 1
- No support aiohttp? HOT 2
- Trio fails under gevent with NotImplementedError: unsupported platform HOT 11
- AttributeError: type object 'GreenSocket' has no attribute 'sendmsg' HOT 4
- Add `TypeVarTuple` to `Nursery.start` HOT 3
- unexpected StopAsyncIteration HOT 6
- Problems with `trio.Lock()` across multiple tasks HOT 4
- exception forwarding in from_thread.run HOT 3
- Regression: unix socket bind does not work with a PathLike argument HOT 3
- Add a Github Action that checks for newsfragment
- move_on_ and fail_ functions should accept shield as a keyword argument
- Using trio with attrs 24.1.0 raises a warning HOT 4
- Make no-test-dependencies CI run use locked resolutions
- Make sure trio works with Read the Docs Addons
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trio.