Re: ConnectionError handling problem

2015-10-01 Thread Cameron Simpson
On 30Sep2015 23:56, Laura Creighton wrote: In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes: Most likely the Ctrl-C interrupts whatever system call is hanging, causing it to return (failed, probably with errno EINTR). And the python program resumes because the OS system c

Re: ConnectionError handling problem

2015-09-30 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes: >Most likely the Ctrl-C interrupts whatever system call is hanging, causing it >to return (failed, probably with errno EINTR). And the python program resumes >because the OS system call has returned. > >Cheers, >Cameron Simp

Re: ConnectionError handling problem

2015-09-30 Thread Cameron Simpson
On 29Sep2015 23:04, shiva upreti wrote: On Friday, September 25, 2015 at 12:55:01 PM UTC+5:30, Cameron Simpson wrote: Ok. You original code says: try: r=requests.post(url, data=query_args) except: print "Connection error" and presumably we think your code is hanging inside the req

Re: ConnectionError handling problem

2015-09-29 Thread shiva upreti
On Friday, September 25, 2015 at 12:55:01 PM UTC+5:30, Cameron Simpson wrote: > On 24Sep2015 22:46, shiva upreti wrote: > >On Friday, September 25, 2015 at 10:55:45 AM UTC+5:30, Cameron Simpson wrote: > >> On 24Sep2015 20:57, shiva upreti wrote: > >> >Thank you Cameron. > >> >I think the problem

Re: ConnectionError handling problem

2015-09-27 Thread Gonzalo V
Hi Cameron. i had the same problems and you have to tell to python what to do with the connect problem. try this: ... except *urllib.error.HTTPError* as e: if e.getcode()==504: disp = "SIN RESPUESTA DEL SERVIDOR" #(No answer from the server) nombre=''

Re: ConnectionError handling problem

2015-09-26 Thread Cameron Simpson
On 26Sep2015 09:46, Gonzalo V wrote: Hi Cameron. i had the same problems and you have to tell to python what to do with the connect problem. Definitely. That's why we're encouraging him to handle specific exceptions. try this: ... except *urllib.error.HTTPError* as e: if e.getcode

Re: ConnectionError handling problem

2015-09-25 Thread Cameron Simpson
On 24Sep2015 22:46, shiva upreti wrote: On Friday, September 25, 2015 at 10:55:45 AM UTC+5:30, Cameron Simpson wrote: On 24Sep2015 20:57, shiva upreti 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

Re: ConnectionError handling problem

2015-09-24 Thread shiva upreti
On Friday, September 25, 2015 at 10:55:45 AM UTC+5:30, Cameron Simpson wrote: > On 24Sep2015 20:57, shiva upreti 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

Re: ConnectionError handling problem

2015-09-24 Thread shiva upreti
On Thursday, September 24, 2015 at 4:09:04 PM UTC+5:30, Laura Creighton wrote: > In a message of Wed, 23 Sep 2015 19:49:17 -0700, shiva upreti writes: > >Hi > >If my script hangs because of the reasons you mentioned above, why doesnt it > >catch ConnectionError? > >My script stops for a while and

Re: ConnectionError handling problem

2015-09-24 Thread shiva upreti
On Thursday, September 24, 2015 at 4:09:04 PM UTC+5:30, Laura Creighton wrote: > In a message of Wed, 23 Sep 2015 19:49:17 -0700, shiva upreti writes: > >Hi > >If my script hangs because of the reasons you mentioned above, why doesnt it > >catch ConnectionError? > >My script stops for a while and

Re: ConnectionError handling problem

2015-09-24 Thread Cameron Simpson
On 24Sep2015 20:57, shiva upreti 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 th

Re: ConnectionError handling problem

2015-09-24 Thread shiva upreti
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. As my code doesnt

Re: ConnectionError handling problem

2015-09-24 Thread shiva upreti
Thank you. I didnt know about keyboard interrupt exception. It means my code hangs without raising any exceptions, what should i do in this case? -- https://mail.python.org/mailman/listinfo/python-list

Re: ConnectionError handling problem

2015-09-24 Thread Cameron Simpson
On 24Sep2015 12:38, Laura Creighton wrote: In a message of Wed, 23 Sep 2015 19:49:17 -0700, shiva upreti writes: If my script hangs because of the reasons you mentioned above, why doesnt it catch ConnectionError? My script stops for a while and when I press CTRL+C, it shows ConnectionError wi

Re: ConnectionError handling problem

2015-09-24 Thread Laura Creighton
In a message of Wed, 23 Sep 2015 19:49:17 -0700, shiva upreti writes: >Hi >If my script hangs because of the reasons you mentioned above, why doesnt it >catch ConnectionError? >My script stops for a while and when I press CTRL+C, it shows ConnectionError >without terminating the process, and the

Re: ConnectionError handling problem

2015-09-23 Thread shiva upreti
On Sunday, September 20, 2015 at 8:11:18 PM UTC+5:30, Laura Creighton wrote: > The discussion about why or why not to use a bare except has gotten us > away from the problem reported, which is "why is my script hanging?" > > In a message of Sat, 19 Sep 2015 17:18:12 +0100, Mark Lawrence writes: >

Re: ConnectionError handling problem

2015-09-20 Thread Laura Creighton
The discussion about why or why not to use a bare except has gotten us away from the problem reported, which is "why is my script hanging?" In a message of Sat, 19 Sep 2015 17:18:12 +0100, Mark Lawrence writes: >> I am learning python. I wrote a script using requests module. >> The scripts runs fi

Re: ConnectionError handling problem

2015-09-20 Thread Jon Ribbens
On 2015-09-20, Chris Angelico wrote: > On Sun, Sep 20, 2015 at 10:45 PM, Jon Ribbens > wrote: >> On 2015-09-19, Mark Lawrence wrote: >>> On 19/09/2015 07:13, shiva upreti wrote: try: r=requests.post(url, data=query_args) except:

Re: ConnectionError handling problem

2015-09-20 Thread Jon Ribbens
On 2015-09-20, Mark Lawrence wrote: > On 20/09/2015 13:45, Jon Ribbens wrote: >> On 2015-09-19, Mark Lawrence wrote: >>> On 19/09/2015 07:13, shiva upreti wrote: try: r=requests.post(url, data=query_args) except: prin

Re: ConnectionError handling problem

2015-09-20 Thread Chris Angelico
On Sun, Sep 20, 2015 at 10:45 PM, Jon Ribbens wrote: > On 2015-09-19, Mark Lawrence wrote: >> On 19/09/2015 07:13, shiva upreti wrote: >>> try: >>> r=requests.post(url, data=query_args) >>> except: >>> print "Connection error" >>

Re: ConnectionError handling problem

2015-09-20 Thread Mark Lawrence
On 20/09/2015 13:45, Jon Ribbens wrote: On 2015-09-19, Mark Lawrence wrote: On 19/09/2015 07:13, shiva upreti wrote: try: r=requests.post(url, data=query_args) except: print "Connection error" Never use a bare ex

Re: ConnectionError handling problem

2015-09-20 Thread Jon Ribbens
On 2015-09-19, Mark Lawrence wrote: > On 19/09/2015 07:13, shiva upreti wrote: >> try: >> r=requests.post(url, data=query_args) >> except: >> print "Connection error" > > Never use a bare except in Python, always handle the bare m

Re: ConnectionError handling problem

2015-09-19 Thread Mark Lawrence
On 19/09/2015 07:13, shiva upreti wrote: I am learning python. I wrote a script using requests module. The scripts runs fine for sometime, but after a while it hangs. When I press CTRL+C it shows ConnectionError even though I have included exception handling. I am not sure as to why it cant hand

ConnectionError handling problem

2015-09-18 Thread shiva upreti
I am learning python. I wrote a script using requests module. The scripts runs fine for sometime, but after a while it hangs. When I press CTRL+C it shows ConnectionError even though I have included exception handling. I am not sure as to why it cant handle ConnectionError when the script runs for