[Tutor] Socket Error Handling Syntax

sparkle Plenty sparkle.plenty12481632 at gmail.com
Tue May 28 19:25:51 CEST 2013


Python 3.3, Windows operating system:

I am communicating with a device using a Python script and I am
coding except clauses in my send and receive functions to handle a
particular error. I can't find a WinError example, and I can't get the
syntax right.  I have researched this and tried the following:

while not_sent:
    try:
        (my socket send code)

    except OSError.WinError.10057
        (this failed)
    except OSError.WSAENOTCONN
        (this failed)
    except OSError.winerror.WSANOTCONN
        (this failed)

I have another general except/as clause already coded and debugged for each
function to catch unexpected errors and shut down.  I need to catch and
handle 10057 exceptions when they occur and keep running.  I know 10057 is
a WinError, which is a subset of OSError, I just can't find the right
syntax for it.  I would appreciate some help on this one.

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130528/98512724/attachment.html>


More information about the Tutor mailing list