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

Add support.catch_threading_exception() #81707

Closed
vstinner opened this issue Jul 9, 2019 · 5 comments
Closed

Add support.catch_threading_exception() #81707

vstinner opened this issue Jul 9, 2019 · 5 comments
Labels
3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

vstinner commented Jul 9, 2019

BPO 37526
Nosy @vstinner
PRs
  • bpo-37526: Add support.catch_threading_exception() #14664
  • [3.8] bpo-37526: Add support.catch_threading_exception() (GH-14664) #14666
  • 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 = None
    closed_at = <Date 2019-07-09.12:37:40.196>
    created_at = <Date 2019-07-09.10:26:30.732>
    labels = ['3.8', 'tests', '3.9']
    title = 'Add support.catch_threading_exception()'
    updated_at = <Date 2019-07-09.12:37:40.192>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-07-09.12:37:40.192>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-07-09.12:37:40.196>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2019-07-09.10:26:30.732>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 37526
    keywords = ['patch']
    message_count = 5.0
    messages = ['347540', '347543', '347545', '347552', '347556']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['14664', '14666']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue37526'
    versions = ['Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 9, 2019

    bpo-1230540 added threading.excepthook() to handle "uncaught exceptions raised by Thread.run()".

    I propose to add support.catch_threading_exception(): context manager to ease catching these exceptions.

    Attached PR implements it.

    @vstinner vstinner added 3.9 only security fixes tests Tests in the Lib/test dir 3.8 only security fixes labels Jul 9, 2019
    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 9, 2019

    See also bpo-36829: Add test.support.catch_unraisable_exception().

    catch_threading_exception() is very close to catch_unraisable_exception().

    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 9, 2019

    New changeset 91b4f7a by Victor Stinner in branch 'master':
    bpo-37526: Add support.catch_threading_exception() (GH-14664)
    91b4f7a

    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 9, 2019

    New changeset 58f2c7f by Victor Stinner (Miss Islington (bot)) in branch '3.8':
    bpo-37526: Add support.catch_threading_exception() (GH-14664) (GH-14666)
    58f2c7f

    @vstinner
    Copy link
    Member Author

    vstinner commented Jul 9, 2019

    Maybe the context manager could recreate attributes (set them to None) if the context manager is used wice, but I'm not sure that I don't want to promote to reuse catch_threading_exception().

    I didn't check if catch_threading_exception() creates a ref cycle. I guess so. It's likely than storing an exception creates a ref cycle. Anyway, __exit__() removes attributes.

    @vstinner vstinner closed this as completed Jul 9, 2019
    @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
    3.8 only security fixes 3.9 only security fixes tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant