Path: csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.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; 'kind,': 0.05; 'except:': 0.07; 'friday,': 0.07; 'cc:addr:python-list': 0.09; 'statements': 0.09; 'that).': 0.09; 'python': 0.10; 'exception': 0.13; '"connection': 0.16; '-rn': 0.16; '>on': 0.16; 'call?': 0.16; 'command,': 0.16; 'command:': 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; 'presume': 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; 'status.': 0.16; 'subject:handling': 0.16; 'wrote:': 0.16; 'laura': 0.18; 'try:': 0.18; 'shell': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'ok.': 0.22; 'subject:problem': 0.22; 'cheers,': 0.22; 'cc:no real name:2**0': 0.22; '(or': 0.23; 'this:': 0.23; 'unix': 0.24; 'header:In-Reply- To:1': 0.24; 'hosting': 0.25; 'header:User-Agent:1': 0.26; 'figure': 0.27; 'issuing': 0.29; 'prints': 0.29; 'print': 0.30; 'connection': 0.30; 'code': 0.30; 'connections': 0.30; 'probably': 0.31; 'possibly': 0.32; 'maybe': 0.33; 'run': 0.33; 'problem': 0.33; 'adjust': 0.33; 'call,': 0.33; 'raising': 0.33; 'received:com.au': 0.33; 'open': 0.33; "i'll": 0.33; 'server': 0.34; 'that,': 0.34; 'quite': 0.35; 'should': 0.36; 'url:non- standard http port': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; 'doing': 0.38; 'someone': 0.38; 'files': 0.38; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'press': 0.61; 'show': 0.62; 'more': 0.63; 'cameron': 0.66; 'elsewhere': 0.66; 'url:6': 0.66; 'directly.': 0.76; '"".': 0.84; 'hanging': 0.84; 'me).': 0.84; 'presumably': 0.84; 'url:172': 0.84; 'utc+5:30,': 0.84; 'examine': 0.95; 'url:16': 0.95; 'url:login': 0.96 Date: Fri, 25 Sep 2015 17:24:30 +1000 From: Cameron Simpson To: shiva upreti Cc: 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: <550e9854-1247-4f6b-b9c7-7c8d7ea6ae37@googlegroups.com> User-Agent: Mutt/1.5.23 (2014-03-12) References: <550e9854-1247-4f6b-b9c7-7c8d7ea6ae37@googlegroups.com> 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=ff-B7xzCdYMA:10 a=pGLkceISAAAA:8 a=nP5_cENUAAAA:8 a=eqZ8MFiUvLYh8_OxlNQA:9 a=CjuIK1q_8ugA:10 a=ldJ9EG8W3yUA:10 a=qiWi7Edwir4A:10 a=NWVoK91CQyQA:10 a=e_9gCKMlLccA: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: 49 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1443165885 news.xs4all.nl 23784 [2001:888:2000:d::a6]:47554 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:97120 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 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. 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. While it is hung, examine the network status. I'll presume you're on a UNIX system of some kind, probably Linux? If not it may be harder (or just require someone other than me). If it is hung in the .post call, quite possibly it has an established connecion to the target server - maybe that server is hanging. The shell command: netstat -rn | fgrep 172.16.68.6 | fgrep 8090 will show every connection to your server hosting the URL "http://172.16.68.6:8090/login.xml". That will tell you if you have a connection (if you are the only person doing the connecting from your machine). If you have the "lsof" program (possibly in /usr/sbin, so "/usr/sbin/lsof") you can also examine the state of your hung Python program. This: lsof -p 12345 will report on the open files and network connections of the process with pid 12345. Adjust to suit: you can find your program's pid ("process id") with the "ps" command, or by backgrounding your program an issuing the "jobs" command, which should show the process id more directly. Cheers, Cameron Simpson