Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'except:': 0.07; 'friday,': 0.07; 'returned.': 0.07; 'errno': 0.09; 'statements': 0.09; 'that).': 0.09; 'python': 0.10; 'causing': 0.13; '"connection': 0.16; '>on': 0.16; 'call?': 0.16; 'error"': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'hangs': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subject:handling': 0.16; 'wrote:': 0.16; 'try:': 0.18; '2015': 0.20; 'ok.': 0.22; 'resumes': 0.22; 'subject:problem': 0.22; 'cheers,': 0.22; 'header:In-Reply-To:1': 0.24; 'script': 0.25; 'header:User-Agent:1': 0.26; 'figure': 0.27; 'print': 0.30; 'code': 0.30; 'probably': 0.31; 'run': 0.33; 'received:com.au': 0.33; 'ubuntu': 0.33; 'open': 0.33; 'that,': 0.34; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; 'things': 0.38; 'why': 0.39; 'whatever': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'hang': 0.60; 'your': 0.60; 'press': 0.61; 'cameron': 0.66; 'elsewhere': 0.66; 'hanging': 0.84; 'presumably': 0.84; 'utc+5:30,': 0.84; 'thing,': 0.93 Date: Thu, 1 Oct 2015 07:30:59 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: ConnectionError handling problem MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=C/8Usl7+ c=1 sm=1 tr=0 a=t6IGaf1l19PsElHJfDn/BA==:117 a=t6IGaf1l19PsElHJfDn/BA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=vrnE16BAAAAA:8 a=kj9zAlcOel0A:10 a=5lJygRwiOn0A:10 a=pGLkceISAAAA:8 a=eGCh0NCxDN6q6p89ImUA:9 a=CjuIK1q_8ugA:10 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443649730 news.xs4all.nl 23786 [2001:888:2000:d::a6]:48734 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97258 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 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. Cheers, Cameron Simpson