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

Make contextlib.redirect_stdout reentrant #63602

Closed
ncoghlan opened this issue Oct 26, 2013 · 4 comments
Closed

Make contextlib.redirect_stdout reentrant #63602

ncoghlan opened this issue Oct 26, 2013 · 4 comments
Assignees
Labels
type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

BPO 19403
Nosy @rhettinger, @ncoghlan
Dependencies
  • bpo-19330: Use public classes for contextlib.suppress and redirect_stdout
  • Files
  • issue19403_reentrant_redirect_stdout.diff: Make redirect_stdout reentrant
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/ncoghlan'
    closed_at = <Date 2013-11-03.07:02:23.977>
    created_at = <Date 2013-10-26.06:43:50.540>
    labels = ['type-feature']
    title = 'Make contextlib.redirect_stdout reentrant'
    updated_at = <Date 2013-11-03.07:02:23.975>
    user = 'https://github.com/ncoghlan'

    bugs.python.org fields:

    activity = <Date 2013-11-03.07:02:23.975>
    actor = 'python-dev'
    assignee = 'ncoghlan'
    closed = True
    closed_date = <Date 2013-11-03.07:02:23.977>
    closer = 'python-dev'
    components = []
    creation = <Date 2013-10-26.06:43:50.540>
    creator = 'ncoghlan'
    dependencies = ['19330']
    files = ['32375']
    hgrepos = []
    issue_num = 19403
    keywords = ['patch']
    message_count = 4.0
    messages = ['201318', '201358', '201514', '202001']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'ncoghlan', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue19403'
    versions = ['Python 3.4']

    @ncoghlan
    Copy link
    Contributor Author

    I realised making contextlib.redirect_stdout reentrant was actually fairly easy (thread safety is inherently impossible due to the process global side effect). Since making it reentrant makes it more user-friendly, I'll tweak the implementation to work that way.

    Need to resolve bpo-19330 first, though.

    As part of this change, the reusable-but-not-reentrant example in the docs needs to be updated to use contextlib.ExitStack rather than this (that's inherently not reentrant, since all the context managers in the stack would be triggered when the innermost context ends).

    @ncoghlan ncoghlan self-assigned this Oct 26, 2013
    @ncoghlan ncoghlan added the type-feature A feature request or enhancement label Oct 26, 2013
    @ncoghlan
    Copy link
    Contributor Author

    I think this change also makes for nicer examples of reentrant (using the updated redirect_stdout) and reusable-but-not-reentrant (using ExitStack) behaviour in the docs.

    @rhettinger
    Copy link
    Contributor

    +1

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 3, 2013

    New changeset 87d49e2cdd34 by Nick Coghlan in branch 'default':
    Close bpo-19403: make contextlib.redirect_stdout reentrant
    http://hg.python.org/cpython/rev/87d49e2cdd34

    @python-dev python-dev mannequin closed this as completed Nov 3, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants