Issue2428
Created on 2015-11-12.17:48:53 by dhable, last changed 2015-11-21.16:30:42 by zyasoft.
msg10466 (view) |
Author: Dan Hable (dhable) |
Date: 2015-11-12.17:48:53 |
|
Running code to showcase the difference is located at
https://gist.github.com/nickmbailey/b047390a5effa1b20856
We're noticing significantly longer times for a Jython socket to connect that does not appear in the CPython version. This delay seems to be causing issues with Twisted's poll reactor, which expects that a socket will connect within 2 times from being fetched from the poll object.
|
msg10471 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-11-13.23:10:17 |
|
I have a fix (socket-EALREADY.diff) that will be shortly committed, once I have implemented corresponding tests.
The problem is not that Jython connect takes longer, but because socket.connect_ex was not returning errno.EALREADY if the connection was in progress. I also added a short wait time to emulate what is done in CPython (1.25ms).
|
msg10475 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-11-14.14:18:34 |
|
Calls to connect_ex on nonblocking sockets should report the sequence:
errno.EINPROGRES (if not immediately connected), errno.EALREADY (for subsequent calls until connected), E.ISCONN (once connected); or the corresponding error. Additionally, code written against the CPython behavior assumes that each poll takes some modest amount of time (this is what accounts for the original bug title, "Jython connect takes significantly longer than CPython socket connect"), or busy waiting loops will fail. Empirically this is about 1-2 milliseconds on my laptop. In the bug fix, I chose 1.25 milliseconds.
See http://www.gnu.org/software/libc/manual/html_node/Connecting.html for more details on connect_ex, which exposes the underlying connect behavior, especially for nonblocking connects.
Fixed as of https://hg.python.org/jython/rev/962002f7d96b
|
msg10476 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-11-14.15:38:42 |
|
Forgot to mention - in fixing this bug, I also fixed a related problem in socket.getsockname when working with ephemeral addresses, both on server and peer sockets. This most likely just impacts Jython's own testing, but one outcome is that test_select_new is now robust.
|
|
Date |
User |
Action |
Args |
2015-11-21 16:30:42 | zyasoft | set | status: pending -> closed |
2015-11-14 15:38:42 | zyasoft | set | messages:
+ msg10476 |
2015-11-14 14:18:35 | zyasoft | set | status: open -> pending resolution: accepted -> fixed messages:
+ msg10475 title: Jython connect takes significantly longer than CPython socket connect -> socket.connect_ex does not properly report connection state sequence |
2015-11-13 23:10:56 | zyasoft | set | assignee: zyasoft resolution: accepted milestone: Jython 2.7.1 |
2015-11-13 23:10:18 | zyasoft | set | files:
+ socket-EALREADY.diff keywords:
+ patch messages:
+ msg10471 nosy:
+ zyasoft |
2015-11-12 17:48:53 | dhable | create | |
|