ConnectionError handling problem
cs at zip.com.au
Wed Sep 30 23:30:59 CEST 2015
On 29Sep2015 23:04, shiva upreti <katewinslet626 at gmail.com> wrote:
>On Friday, September 25, 2015 at 12:55:01 PM UTC+5:30, Cameron Simpson wrote:
>> Ok. You original code says:
>> r=requests.post(url, data=query_args)
>> print "Connection error"
>> and presumably we think your code is hanging inside the requests.post call? You
>> should probably try to verify that, because if it is elsewhere you need to
>> figure out where (lots of print statements is a first start on that).
>> I would open two terminals. Run your program until it hangs in one.
[...various things to do to check _exactly_ where the hang is occurring...]
>Yes I use ubuntu 14.04. I will try what you suggested. But I cant understand
>one thing, for whatever reason the script is hanging, why does it resumes
>almost instantaneously when I press CTRL+C.
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.
Cameron Simpson <cs at zip.com.au>
More information about the Python-list