Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97114

Re: ConnectionError handling problem

Date 2015-09-25 14:59 +1000
From Cameron Simpson <cs@zip.com.au>
Subject Re: ConnectionError handling problem
References <4852c463-0c47-4fef-956a-c6c20f59fc0e@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.160.1443158719.28679.python-list@python.org> (permalink)

Show all headers | View raw


On 24Sep2015 20:57, shiva upreti <katewinslet626@gmail.com> wrote:
>Thank you Cameron.
>I think the problem with my code is that it just hangs without raising any exceptions. And as mentioned by Laura above that when I press CTRL+C, it just catches that exception and prints ConnectionError which is definitely a lie in this case as you mentioned.

Update it to report the _actual_ exception received. (If any.) At least then 
you will be sure.

>As my code doesnt raise any exception by itself, instead just hangs,

So, no "ConnectionError" message?

>I wont be able to characterize the exceptions and handle them individually.

Can you repost you code once it is modified to display the precise exception.

Note that one easy way to catch all but progressively handle specific 
exceptions looks like this:

  try:
     ... code ...
  except OSError as e:
    print OSError received, specifics are:", e
  except Exception as e:
    print "unhandled exception:", e
    break

and so on, inserting the exception types _above_ the final "except" as you add 
actions for them.

Cheers,
Cameron Simpson <cs@zip.com.au>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 09:25 +1000
  Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-24 20:57 -0700
    Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 14:59 +1000
      Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-24 22:46 -0700
        Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 17:24 +1000
          Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-29 23:04 -0700
            Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-10-01 07:30 +1000
            Re: ConnectionError handling problem Laura Creighton <lac@openend.se> - 2015-09-30 23:56 +0200

csiph-web