This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: asyncore.dispatcher does not handle windows socket error code correctly (namely WSAEWOULDBLOCK 10035)
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.2
Status: closed Resolution: wont fix
Dependencies: Superseder: Close asyncore/asynchat/smtpd issues and list them here
View: 45552
Assigned To: Nosy List: McNetic, dvitek, vstinner
Priority: normal Keywords: patch

Created on 2012-09-20 11:12 by McNetic, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
p.patch dvitek, 2018-01-03 21:05
Messages (4)
msg170799 - (view) Author: Nicolai Ehemann (McNetic) Date: 2012-09-20 11:12
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
  data = self.socket.recv(buffer_size)
    data = self.socket.recv(buffer_size)
  except socket.error as e:
    if 10035 == e.errno:
      raise e

The differences between windows and unix non-blocking sockets are summarized quite nice here:

The original documentation from microsoft can be found here:
msg221734 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-06-27 21:04
This issue looks like a duplicate of the issue #16133.
msg309433 - (view) Author: David Vitek (dvitek) Date: 2018-01-03 21:05
It doesn't look like the fix for issue #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.
msg309447 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-01-03 22:44
I reopen the issue since David Vitek proposed a patch.
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60186
2021-10-21 11:26:38iritkatrielsetstatus: open -> closed
superseder: asyncore.dispatcher.recv doesn't handle EAGAIN / EWOULDBLOCK -> Close asyncore/asynchat/smtpd issues and list them here
resolution: wont fix
stage: resolved
2018-01-03 22:44:16vstinnersetstatus: closed -> open
resolution: duplicate -> (no value)
messages: + msg309447
2018-01-03 21:05:45dviteksetfiles: + p.patch

nosy: + dvitek
messages: + msg309433

keywords: + patch
2014-07-24 17:20:49vstinnersetstatus: open -> closed
superseder: asyncore.dispatcher.recv doesn't handle EAGAIN / EWOULDBLOCK
resolution: duplicate
2014-06-27 21:04:38vstinnersetnosy: + vstinner
messages: + msg221734
2012-09-20 11:12:49McNeticcreate