Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Dennis Lee Bieber Newsgroups: comp.lang.python Subject: Re: urllib2.urlopen() crashes on Windows 2008 Server Date: Fri, 04 Dec 2015 13:16:40 -0500 Organization: IISS Elusive Unicorn Lines: 60 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de C6SILlRWHvhRWeLOo9z/sg/gaU4lqxKpDJ2boEhbwXNg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '"""': 0.05; 'exception.': 0.07; 'socket': 0.07; 'terminated': 0.07; 'subject:Windows': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'socket.error': 0.09; 'string)': 0.09; 'underlying': 0.09; 'python': 0.10; 'exception': 0.13; 'stack': 0.13; 'subsequent': 0.15; '2.6:': 0.16; 'close()': 0.16; 'errno,': 0.16; 'intervening': 0.16; 'program?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'tcp': 0.16; 'tcp,': 0.16; 'trap': 0.16; 'wrote:': 0.16; 'string': 0.17; 'url:home': 0.18; '2015': 0.20; 'sends': 0.22; 'defined': 0.23; 'dec': 0.23; '(this': 0.24; 'module': 0.25; 'header:X-Complaints- To:1': 0.26; 'error': 0.27; '+0000': 0.27; 'fri,': 0.27; 'data,': 0.27; 'errors.': 0.27; 'went': 0.28; 'host.': 0.29; 'peer': 0.29; 'protocols': 0.29; 'subject:skip:u 10': 0.29; 'reset': 0.29; 'connection': 0.30; 'server.': 0.30; 'connections': 0.30; 'regardless': 0.31; 'returned': 0.32; 'changed': 0.33; 'class': 0.33; 'url:python': 0.33; 'call,': 0.33; 'raised': 0.33; 'true.': 0.33; 'similar': 0.33; 'server': 0.34; 'configured': 0.35; 'something': 0.35; 'remote': 0.35; 'should': 0.36; 'url:org': 0.36; 'child': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'operating': 0.37; 'client': 0.37; 'received:org': 0.37; 'mac': 0.37; 'charset:us-ascii': 0.37; 'version': 0.38; 'names': 0.38; 'wrong': 0.38; 'data': 0.39; 'application': 0.39; 'system.': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'telling': 0.61; 'per': 0.62; 'within': 0.64; 'accompanying': 0.67; '(utc),': 0.84; '>how': 0.84; 'non-zero': 0.84; 'termed': 0.84; 'dennis': 0.91; 'subject:Server': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: adsl-108-73-118-181.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: , Xref: csiph.com comp.lang.python:100010 On Fri, 4 Dec 2015 13:00:32 +0000 (UTC), Ulli Horlacher declaimed the following: >Dennis Lee Bieber wrote: >> >> Per MSDN: >> """ >> WSAECONNRESET >> 10054 >> >> >> >> Connection reset by peer. >> >> An existing connection was forcibly closed by the remote host. > >This is not true. >The server is under my control. Die client has terminated the connection >(or a router between). > http://stackoverflow.com/questions/16888429/how-to-make-a-hard-abortive-close-on-a-tcp-connection Case 2: linger->l_onoff is non-zero and linger->l_linger is zero: A close() returns immediately. The underlying stack discards any unsent data, and, in the case of connection-oriented protocols such as TCP, sends a RST (reset) to the peer (this is termed a hard or abortive close). All subsequent attempts by the peer's application to read()/recv() data will result in an ECONNRESET. The odds are still good that something on the server is configured to not make a clean shutdown of TCP connections (a router should not be involved as the TCP connection is from client IP to server IP, regardless of intervening MAC Ethernet routing). The RST is coming from the server. > >How can I trap this within the python program? >I see no exception. It's a socket error https://docs.python.org/2/library/socket.html """ exception socket.error This exception is raised for socket-related errors. The accompanying value is either a string telling what went wrong or a pair (errno, string) representing an error returned by a system call, similar to the value accompanying os.error. See the module errno, which contains names for the error codes defined by the underlying operating system. Changed in version 2.6: socket.error is now a child class of IOError. """ -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/