Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate replacing addfinalizer with ExitStack #5592

Open
graingert opened this issue Jul 10, 2019 · 6 comments
Open

Investigate replacing addfinalizer with ExitStack #5592

graingert opened this issue Jul 10, 2019 · 6 comments
Labels
topic: fixtures anything involving fixtures directly or indirectly type: refactoring internal improvements to the code

Comments

@graingert
Copy link
Member

addfinalizer can be implemented in terms of adding a callback to a stack

it would be interesting if there was a per usage scope fixture for eexit stacks,

then each fixture could get a very own exit stack in a well expressed manner (and if each fixture had one, it wouldnt be as bad to expose it)

Originally posted by @RonnyPfannschmidt in #5589 (comment)

@graingert graingert changed the title addfinalizer can be implemented in terms of adding a callback to a stack Investigate replacing addfinalizer with ExitStack Jul 10, 2019
@graingert
Copy link
Member Author

note: ExitStack exposes pop_all any implementation would have to remove such access

@graingert
Copy link
Member Author

graingert commented Jul 10, 2019

@RonnyPfannschmidt how about exposing request.exit_stack as an instance of:

class RequestExitStack(contextlib.ExitStack):
    def pop_all(self):
        raise NotImplimentedError

@graingert
Copy link
Member Author

graingert commented Jul 10, 2019

However this is only if there's a usecase for addfinalizer that can't be replaced with a yield fixture using ExitStack

@RonnyPfannschmidt
Copy link
Member

@graingert i'd like to defer exporting exit stacks until they are a "per fixture request" style/type of fixture

if each fixture request has a own exit stack, then its fine if a fixture pops all its things

@nicoddemus nicoddemus added topic: fixtures anything involving fixtures directly or indirectly type: refactoring internal improvements to the code labels Jul 11, 2019
@nicoddemus
Copy link
Member

@RonnyPfannschmidt did you ever get a chance to read #4871? It is related to how finalizers are handled.

@RonnyPfannschmidt
Copy link
Member

no, will do now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: fixtures anything involving fixtures directly or indirectly type: refactoring internal improvements to the code
Projects
None yet
Development

No branches or pull requests

3 participants