ConnectionError handling problem

Cameron Simpson cs at
Fri Sep 25 06:59:19 CEST 2015

On 24Sep2015 20:57, shiva upreti <katewinslet626 at> 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:

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

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

Cameron Simpson <cs at>

More information about the Python-list mailing list