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.

Author YoSTEALTH
Recipients YoSTEALTH
Date 2017-01-06.22:55:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483743358.76.0.0752156268987.issue29186@psf.upfronthosting.co.za>
In-reply-to
Content
TimeoutError isn't being raised?

My Python Version: 3.5.1 (64bit, linux)

# Document:
https://docs.python.org/3/library/exceptions.html#TimeoutError
""" exception TimeoutError
    Raised when a system function timed out at the system level. Corresponds to errno ETIMEDOUT.
New in version 3.3: All the above OSError subclasses were added.
See also PEP 3151 - Reworking the OS and IO exception hierarchy """

# PEP: According to pep-3151
link: https://www.python.org/dev/peps/pep-3151/
""" TimeoutError : connection timed out (ETIMEDOUT); this can be re-cast as a generic timeout exception, replacing socket.timeout and also useful for other types of timeout (for example in Lock.acquire()) """


# This Does NOT Work:
def Send(conn, data):
    # Set Timeout.
    conn.settimeout(3.0)
    try:
        while data:
            sent = conn.send(data)
            data = data[sent:]
    except TimeoutError as e:
        print("TimeoutError:", e)  #
        close_connection()
    else:
        pass  # Do Stuff...


# This Works
def Send(conn, data):
    # Set Timeout.
    conn.settimeout(3.0)
    try:
        while data:
            sent = conn.send(data)
            data = data[sent:]
    except socket.timeout as e:
        print("socket.timeout:", e)  # socket.timeout: timed out
        close_connection()
    else:
        pass  # Do Stuff...


# This Works
def Send(conn, data):
    # Set Timeout.
    conn.settimeout(3.0)
    try:
        while data:
            sent = conn.send(data)
            data = data[sent:]
    except OSError as e:
        print('ERROR Send:', e)  # ERROR Send: timed out
        close_connection()
    else:
        pass  # Do Stuff...


According to PEP "TimeoutError" is suppose to replace "socket.timeout" but it doesn't seem to work! Any ideas why?
History
Date User Action Args
2017-01-06 22:55:58YoSTEALTHsetrecipients: + YoSTEALTH
2017-01-06 22:55:58YoSTEALTHsetmessageid: <1483743358.76.0.0752156268987.issue29186@psf.upfronthosting.co.za>
2017-01-06 22:55:58YoSTEALTHlinkissue29186 messages
2017-01-06 22:55:58YoSTEALTHcreate