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.

classification
Title: asyncore.dispactcher: incorrect connect
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: josiahcarlson Nosy List: josiahcarlson, klimkin, sankov_da
Priority: normal Keywords:

Created on 2004-02-02 16:04 by sankov_da, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg19877 - (view) Author: Sankov Dmitry Alexandrovich (sankov_da) Date: 2004-02-02 16:04
When i use non-blocking socket, connect() method of
asyncore.dispatcher class looks like works incorrect.

Example: if connection have not established then socket
merely closed and handle_error not called and no
exception throwed.

One more example: if writable() and readble() methods
returns zero than handle_connect() will never be called
even if connection will be established.

Thanks.
msg19878 - (view) Author: Alexey Klimkin (klimkin) Date: 2004-03-04 08:22
Logged In: YES 
user_id=410460

Patch #909005 fixes the problem.
msg19879 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2007-01-06 23:05
It sounds as though the original poster is passing a socket that has been created, but which is not yet connected, to the dispatcher constructor.

We should update the documentation to state that either the user should pass a completely connected socket (as returned by socket.accept(), or which has connected as the result of a a blocking socket.connect() call), or use the .create_socket() and .connect() methods of the dispatcher.
msg19880 - (view) Author: Alexey Klimkin (klimkin) Date: 2007-01-08 10:37
It's about _non-blocking_ socket. Socket has been created and connect called. However, for non-blocking socket connect returns immediately. The patch allows to use connect in non-blocking manner. I don't see any reason of limiting socket to be connected in blocking manner.
msg19881 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2007-01-08 17:02
According to my reading, the only change necessary to make the semantics equivalent for a non-blocking socket for which .connect() has been called is to change a portion of the dispatcher's __init__ method to:

    try:
        self.addr = sock.getpeername()
    except socket.error:
        # if we can't get the peer name, we haven't connected yet
        self.connected = False
msg19882 - (view) Author: Alexey Klimkin (klimkin) Date: 2007-01-08 20:52
I was working with Dmitry desk by desk :), but I don't remember, what did he really mean with his "broken" english :). The main problem was in impossibility to connect to another peer in non-blocking manner. The patch contains the workaround code, which changes original behaviour significantly. You may seek for your own way to fix blocking connect there. 
msg69217 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2008-07-03 18:03
Fixed in trunk, will be fixed in 3.0 this weekend.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39891
2008-07-03 18:03:13josiahcarlsonsetstatus: open -> closed
resolution: fixed
messages: + msg69217
2004-02-02 16:04:37sankov_dacreate