Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Pavlos Parissis Newsgroups: comp.lang.python Subject: intermittent ValueErrors from subprocess Date: Sun, 15 May 2016 17:49:49 +0200 Lines: 103 Message-ID: References: <57389A9D.1010205@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NdDh6tjMhghA2dghThnpLE85d6ba1SjeK" X-Trace: news.uni-berlin.de zrFqQjUA6FvyEMnxLBLdGwzuxrIGgo4YuT52eywcfA0Q== 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; 'else:': 0.03; 'error:': 0.05; 'dev': 0.07; 'executed': 0.07; 'valueerror:': 0.07; 'cmd': 0.09; 'exception:': 0.09; 'url:github': 0.09; 'valueerror': 0.09; 'thread': 0.10; 'python': 0.10; 'exception': 0.13; "'to',": 0.16; 'cmd,': 0.16; 'filename:fname piece:signature': 0.16; 'intermittent': 0.16; 'loopback': 0.16; 'received:192.168.0.103': 0.16; 'received:74.125.82.46': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reproduce': 0.16; 'running:': 0.16; 'subprocess': 0.16; 'threads': 0.16; 'try:': 0.18; 'runs': 0.18; 'skip:" 30': 0.20; 'parse': 0.22; 'cheers,': 0.22; 'this:': 0.23; 'header:User-Agent:1': 0.26; 'question': 0.27; 'skip:u 20': 0.28; 'interface': 0.29; 'consequence': 0.29; 'code': 0.30; 'anyone': 0.32; '[1]': 0.32; 'dies': 0.33; 'raised': 0.33; 'message- id:@gmail.com': 0.34; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'so,': 0.35; 'could': 0.35; 'false': 0.35; 'happened': 0.35; 'path': 0.35; 'stable': 0.35; 'unknown': 0.35; 'quite': 0.35; 'received:74.125.82': 0.35; 'but': 0.36; 'assigned': 0.36; 'to:addr:python-list': 0.36; 'hi,': 0.38; 'data': 0.39; 'subject:from': 0.39; "didn't": 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'behavior': 0.61; 'address': 0.61; 'avoid': 0.61; 'show': 0.62; 'more': 0.63; 'here:': 0.63; 'times': 0.63; 'object:': 0.84; 'url:master': 0.84; 'before?': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version; bh=PQ02hz/pnVndFG5pO98nOfrk5z39Qdj47T2elA1epKI=; b=O0VAz/YH1EKN79f2fKhXQkOVng4MGnisb1HajaLFIV3Suzx0zu6XbU3uw4RaSBMX8N wdvwsmR2nwinm1hkjehKXVmjHJgD/Rqw8K4NxW4cth7FjZrzfyy6ZWsATRjDZkCcQitt O/aARdXX33bgl6RTbiBq0B5Vfqh+mt2E48LiRKuGgEd1vghclwmR3n+sqDOn7CHup6qD RHDQnvgz2URyTboArLWDXu25plyduYV8+e0UiDAHR5FVXiCedMr899CitAIt0JXSy8WD EGtgMJUU++WfEcQcwKMWYPTgRAVtF3OptfwOehxCHyf4n5Bcjw9ZsleLlDbhaYNt3/5l +gCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=PQ02hz/pnVndFG5pO98nOfrk5z39Qdj47T2elA1epKI=; b=IPnl37JINPv9TtSoUs+kSOLzDVBQ1B9nCtKmLcMYCcnP6ln6IXXi7VpWZ+qE4HCuiL JQLEzPoSpgKgB67vBplFKW6IUoP0HTrr0hbWHXLJGB7Qw/6fhqgUAhO0+2wE91SMG1Uh TwaiFPxzHTIcB/3yP+9PZ7cyvNkczS4MDLUCsPRys19wJOfXmzfO1ZLOQhKg4mbqR1Au na8HLMN5Fi6+qKTXioSPpzyddORQlaQtnbzMud2CvL0E/sqSSVjPr7DuiRE75WQMCjZS wwEwjptUAJMjuMVjLzI0lmZJ5F4U8ia3cLuoElVA97pBEMLx91DtKBFlO7vOWjLTu94r R09g== X-Gm-Message-State: AOPr4FWikeW9wCHJcrGZGodpl0FFzcoa8D0XD4xP3YwJ7TfbRjGxesLebOtbQip2PNMP2w== X-Received: by 10.194.79.70 with SMTP id h6mr28754585wjx.157.1463327392377; Sun, 15 May 2016 08:49:52 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <57389A9D.1010205@gmail.com> Xref: csiph.com comp.lang.python:108639 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --NdDh6tjMhghA2dghThnpLE85d6ba1SjeK Content-Type: multipart/mixed; boundary="6OUiEmRlAkcevUuu3M7lC4M3eBCHtgJ1k" From: Pavlos Parissis To: python-list@python.org Message-ID: <57389A9D.1010205@gmail.com> Subject: intermittent ValueErrors from subprocess --6OUiEmRlAkcevUuu3M7lC4M3eBCHtgJ1k Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I get intermittent ValueErrors[1] from subprocess when I check if an IP is assigned to loopback interface by running: /sbin/ip address show dev lo to 10.52.12.2/32 I use subprocess.check_output like this: cmd =3D [ '/sbin/ip', 'address', 'show', 'dev', "{}".format(self.config['interface']), 'to', "{}".format(self.config['ip_prefix']), ] try: out =3D subprocess.check_output( cmd, universal_newlines=3DTrue, timeout=3D1) except subprocess.CalledProcessError as error: return True except subprocess.TimeoutExpired: return True else: if self.config['ip_prefix'] in out: return True else: return False and I get the following exception: ValueError: Invalid file object: <_io.TextIOWrapper name=3D11 encoding=3D'UTF-8'> As a consequence of the raised exception thread dies and I now catch ValueError in the same try block in order to avoid the crash. It has happened ~5 times and this code is executed from multiple threads and every ~10secs on several(~40) systems for more than 18months. So, it is quite impossible for me to reproduce it. It could be that the system returns corrupted data or python fails for some unknown reason to parse the output. The program uses Python 3.4.4 and runs on Debian stable and CentOS 6/7. The full code path in question can be found here: https://github.com/unixsurfer/anycast_healthchecker/blob/master/anycast_h= ealthchecker/servicecheck.py#L90 I did a search on bugs.python.org about it but I didn't find anything. Has anyone seen this behavior before? Cheers, Pavlos [1] https://gist.github.com/unixsurfer/67db620d87f667423f6f6e3a04e0bff5 --6OUiEmRlAkcevUuu3M7lC4M3eBCHtgJ1k-- --NdDh6tjMhghA2dghThnpLE85d6ba1SjeK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXOJqeAAoJEIP8ktofcXa58RIQAKcYGnkUoIE5rhBlQeC4Ge17 qJSikGUu0DqFKDXbTDSxS34ng8OzHVK32E4S+ZlC+gQKaL36waHNdG51qvAfZW3y C+pdcj0iPR4CjJYB4oECSxdhCnZXy3Mev6YpOowb05d7qtnZzvZNITGuiffjj3+D FmbDr4Jha+GLOVnPTScVaVVZKEx1eaA/HV6rL4OShWiK99M7Xtd3le2zCLKAJcT0 R/8CpIajqfPphfQN26Ef5qTiFEwgOHBEl9W5HBUXUAfcEIfU8HpyQFJVzTNU6cRy A8+daEOxJTEOiuF91VMFv5n44UVwcz1vXwXpQKKaA+nZfedb4aan8rI0gzHsV0Ly cqEuiNE89NrTVy5bgnTAWGtvWvXUc6HQeqTDnqZLcImwZITZI564D1NUekALgW3X zviVCpxfKmcSJD0msQNg54ZdOl0tg964ISNYVC05DCpQPCoXjTMgPH8M/Ec/Ycoy yydU3dUS1PuATYBvtUBk7R8c4wtmDaEXZuYCwCzJLR9jYfDEV4kiIi0plwJONUGy Z6eVh1FlmoskctRGL5K6ZNimWbB4fVJ4rbIpMF/UFrjKX5Mu6qiHQZydU/0CMljA bSnDqWLFgiyZ0z4jsrMmDn+wXHL7mI7capYY4vvBfuXLIjA3bOlzU/QPFSMkgWno H5rs8+g8QnC/XkYU0a8B =pGdX -----END PGP SIGNATURE----- --NdDh6tjMhghA2dghThnpLE85d6ba1SjeK--