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

selectors: raise an exception if the selector is closed #67414

Closed
vstinner opened this issue Jan 12, 2015 · 4 comments
Closed

selectors: raise an exception if the selector is closed #67414

vstinner opened this issue Jan 12, 2015 · 4 comments

Comments

@vstinner
Copy link
Member

BPO 23225
Nosy @gvanrossum, @vstinner, @1st1, @Martiusweb
Files
  • close_selector.patch
  • 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 2015-01-13.09:07:09.541>
    created_at = <Date 2015-01-12.11:06:01.534>
    labels = ['expert-asyncio']
    title = 'selectors: raise an exception if the selector is closed'
    updated_at = <Date 2015-01-13.09:07:09.541>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2015-01-13.09:07:09.541>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-01-13.09:07:09.541>
    closer = 'vstinner'
    components = ['asyncio']
    creation = <Date 2015-01-12.11:06:01.534>
    creator = 'vstinner'
    dependencies = []
    files = ['37682']
    hgrepos = []
    issue_num = 23225
    keywords = ['patch']
    message_count = 4.0
    messages = ['233881', '233890', '233908', '233911']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'vstinner', 'neologix', 'python-dev', 'yselivanov', 'martius']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue23225'
    versions = ['Python 3.4', 'Python 3.5']

    @vstinner
    Copy link
    Member Author

    I propose to raise a RuntimeError exception on operations of a selector when the selector is closed.

    I'm not sure that RuntimeError is the most common exception:

    • io and gzip raise ValueError
    • asyncio raises RuntimeError (and selectors is "linked" to asyncio)
    • multiprocessing raises OSError
    • dbm.dumb raises dbm.dumb.error

    This issue is related to the issue bpo-23209 which propopses to set the _map attribute to None when in the close() method.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Jan 12, 2015

    RuntimeError sounds better to me (raising ValueError when no value is
    provided, e.g. in select() sounds definitely strange).

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 13, 2015

    New changeset 1544bdc409be by Victor Stinner in branch '3.4':
    Issue bpo-23209, bpo-23225: selectors.BaseSelector.close() now clears its internal
    https://hg.python.org/cpython/rev/1544bdc409be

    New changeset 6e7403bc906f by Victor Stinner in branch 'default':
    Issue bpo-23209, bpo-23225: selectors.BaseSelector.get_key() now raises a
    https://hg.python.org/cpython/rev/6e7403bc906f

    @vstinner
    Copy link
    Member Author

    Oh, I forgot Python 3.4. Changing the behaviour of get_key() in a minor Python version (3.4.x) would break the compatibility. I used Martin Richard's patch for Python 3.4: raise a KeyError if the selector is closed.

    I commit my change to Python 3.5 and Tulip.

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant