Skip to content

Original error not present in traceback #830

Answered by graingert
davidbrochart asked this question in Q&A
Discussion options

You must be logged in to vote

There's a mistake in how you are running your AsyncExitStack:

--- before.py	2024-11-30 07:16:46.519537586 +0000
+++ after.py	2024-11-30 07:17:41.005645305 +0000
@@ -10,9 +10,9 @@
     async def __aenter__(self):
         async with AsyncExitStack() as exit_stack:
             self.task_group = await exit_stack.enter_async_context(create_task_group())
-            self._exit_stack = exit_stack.pop_all()
             self.task_group.start_soon(self.task)
             await self.started.wait()
+            self._exit_stack = exit_stack.pop_all()
         return self
 
     async def __aexit__(self, exc_type, exc_value, exc_tb):

the pop all needs to be the absolute last operation before the r…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@davidbrochart
Comment options

Answer selected by davidbrochart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants