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

asyncore.dispatcher does not handle windows socket error code correctly (namely WSAEWOULDBLOCK 10035) #60186

Closed
McNetic mannequin opened this issue Sep 20, 2012 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@McNetic
Copy link
Mannequin

McNetic mannequin commented Sep 20, 2012

BPO 15982
Nosy @vstinner
Superseder
  • bpo-45552: Close asyncore/asynchat/smtpd issues and list them here
  • Files
  • p.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 2021-10-21.11:26:38.203>
    created_at = <Date 2012-09-20.11:12:49.681>
    labels = ['type-bug', 'library']
    title = 'asyncore.dispatcher does not handle windows socket error code correctly (namely WSAEWOULDBLOCK 10035)'
    updated_at = <Date 2021-10-21.11:26:38.202>
    user = 'https://bugs.python.org/McNetic'

    bugs.python.org fields:

    activity = <Date 2021-10-21.11:26:38.202>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-21.11:26:38.203>
    closer = 'iritkatriel'
    components = ['Library (Lib)']
    creation = <Date 2012-09-20.11:12:49.681>
    creator = 'McNetic'
    dependencies = []
    files = ['47363']
    hgrepos = []
    issue_num = 15982
    keywords = ['patch']
    message_count = 4.0
    messages = ['170799', '221734', '309433', '309447']
    nosy_count = 3.0
    nosy_names = ['vstinner', 'dvitek', 'McNetic']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45552'
    type = 'behavior'
    url = 'https://bugs.python.org/issue15982'
    versions = ['Python 3.2']

    @McNetic
    Copy link
    Mannequin Author

    McNetic mannequin commented Sep 20, 2012

    There are some differences between win32 and other os socket implementations. One specific I found is that in windows, non-blocking socket apis will return WSAEWOULDBLOCK or 10035 instead of EWOULDBLOCK.

    This causes recv() in asyncore.dispatcher to raise an unhandled exception instead of continuing gracefully.

    The fix could maybe be as simple as replacing line 384 in asyncore.py:
    data = self.socket.recv(buffer_size)
    with
    try:
    data = self.socket.recv(buffer_size)
    except socket.error as e:
    if 10035 == e.errno:
    pass
    else:
    raise e

    The differences between windows and unix non-blocking sockets are summarized quite nice here: http://itamarst.org/writings/win32sockets.html

    The original documentation from microsoft can be found here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx

    @McNetic McNetic mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 20, 2012
    @vstinner
    Copy link
    Member

    This issue looks like a duplicate of the issue bpo-16133.

    @dvitek
    Copy link
    Mannequin

    dvitek mannequin commented Jan 3, 2018

    It doesn't look like the fix for issue bpo-16133 fixed this problem, or perhaps it only fixed it for asynchat but not asyncore.

    I have attached a patch (against python 2, since this is where I needed it fixed). The patch treats WSA flavors of all errno values in the same way that the non-WSA flavors were treated before.

    It is the intent that no direct references to errno values persist after applying this patch. The patch fixed my particular issue, but I certainly haven't tested every new error condition.

    @vstinner
    Copy link
    Member

    vstinner commented Jan 3, 2018

    I reopen the issue since David Vitek proposed a patch.

    @vstinner vstinner reopened this Jan 3, 2018
    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants