[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2022-02-23 Thread Andreas H.
Andreas H. added the comment: Inside the discussion an ExitPool class is sketched (https://mail.python.org/archives/list/python-id...@python.org/message/66W55FRCYMYF73TVMDMWDLVIZK4ZDHPD/), which provides this removal of context managers. What I learned is that this would have different

[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2022-02-18 Thread Václav Brožík
Václav Brožík added the comment: There was an interesting discussion about this problem in 2015-12: https://mail.python.org/archives/list/python-id...@python.org/thread/Y3SLBJHJHAMBEZJWRXEJ5LE5JBVNE7XS/ (https://groups.google.com/g/python-ideas/c/l2FcErYbjfo - for the case the link above rots)

[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2022-02-18 Thread Václav Brožík
Change by Václav Brožík : -- nosy: +vbrozik ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Andreas H.
Andreas H. added the comment: I see your point. But even with `pop` or `remove` it is still a stack or stack-like. In the normal case the context managers are still released in reverse order as they were added. Order cannot be changed arbitrarily. There is just the additional function of

[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If you can remove context managers in arbitrary order it is no longer a stack. I think that it is just a wrong tool for your problem. Just maintain a collection of opened connections. Set or dict can be better that list or deque. -- nosy:

[issue45184] Add `pop` function to remove context manager from (Async)ExitStack

2021-09-13 Thread Andreas H.
New submission from Andreas H. : Currently it is not possible to remove context managers from an ExitStack (or AsyncExitStack). Workarounds are difficult and generally do accesses implementation details of (Async)ExitStack. See e.g. https://stackoverflow.com/a/37607405. It could be done as