Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97258

Re: ConnectionError handling problem

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 <cameron@cskk.homeip.net>
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 <cs@zip.com.au>
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 <ff56fdf3-e40b-4ebf-8f4a-524f3ce61fbd@googlegroups.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <ff56fdf3-e40b-4ebf-8f4a-524f3ce61fbd@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=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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.278.1443649730.28679.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 29Sep2015 23:04, shiva upreti <katewinslet626@gmail.com> 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 <cs@zip.com.au>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 09:25 +1000
  Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-24 20:57 -0700
    Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 14:59 +1000
      Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-24 22:46 -0700
        Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-09-25 17:24 +1000
          Re: ConnectionError handling problem shiva upreti <katewinslet626@gmail.com> - 2015-09-29 23:04 -0700
            Re: ConnectionError handling problem Cameron Simpson <cs@zip.com.au> - 2015-10-01 07:30 +1000
            Re: ConnectionError handling problem Laura Creighton <lac@openend.se> - 2015-09-30 23:56 +0200

csiph-web