Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108648
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Pavlos Parissis <pavlos.parissis@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: intermittent ValueErrors from subprocess |
| Date | Mon, 16 May 2016 00:32:02 +0200 |
| Lines | 108 |
| Message-ID | <mailman.5.1463351527.19823.python-list@python.org> (permalink) |
| References | <57389A9D.1010205@gmail.com> <CAPTjJmp1H99HKmEarskE1b-ia0=KFDBTpfU+cWt6vVFeJtBHZg@mail.gmail.com> <5738F8E2.1030403@gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CEGQ9EbT41qIlqpu9mfhRqHoj01gR92Oa" |
| X-Trace | news.uni-berlin.de RLjBTicGLASY0Af/VoAbXAKkzF7lnCM4MJYc2ircHWdA== |
| Return-Path | <pavlos.parissis@gmail.com> |
| 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; '16,': 0.03; 'cpython': 0.05; 'error:': 0.05; 'converts': 0.07; 'skip:/ 10': 0.07; 'valueerror:': 0.07; 'cc:addr:python-list': 0.09; 'cmd': 0.09; 'exception:': 0.09; 'url:github': 0.09; 'exception': 0.13; "'to',": 0.16; '2016': 0.16; 'cmd,': 0.16; 'descriptor.': 0.16; 'descriptors,': 0.16; 'did,': 0.16; 'filename:fname piece:signature': 0.16; 'received:192.168.0.103': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sudo': 0.16; 'wrote:': 0.16; 'integer': 0.18; 'string,': 0.18; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'skip:" 30': 0.20; 'problem:': 0.22; 'am,': 0.23; '(you': 0.23; 'this:': 0.23; 'thanks,': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'skip:u 20': 0.28; 'there.': 0.30; 'message-id:@gmail.com': 0.34; 'file': 0.34; 'except': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'false': 0.35; 'nothing.': 0.35; 'received:74.125.82': 0.35; 'possible': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'sources': 0.37; 'does': 0.39; 'subject:from': 0.39; 'unable': 0.39; 'received:192': 0.39; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'object:': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=T9CDuFGg8JT37jaukF2TKRNOQZTbH+671iKJU5fLeRw=; b=Wg6Am1wPvf7umtjAhIaOtiIkKxwCg/QIEhSb/Enwzgs3Xh4IqneKT2sYFDQTKs+fmQ SvxSYAvdwiOJolCtwRocmg/D4avr234BoNsYuxWgpDaH/hLhly4BC1r0G7hqkJwO7szw NZSgKgVrQFShGAxelY7+ia0bkpvOubFpdjI+Sz2tAZHTdD7SmLx6yaAYGtOMG5VNiLmY /gO7MWPqJ3Vk/NA4C+p+BBglNyBx3DlGTw8rZF2F3MD8fLymrFUcLs8sAjDTx2hkntNN os3rb7BnpenvHEGf4NvKdurElBRk0GGrLIWHsus7U5JvFPiA3eWIrzGCgl5E06rO5NeL Nffg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=T9CDuFGg8JT37jaukF2TKRNOQZTbH+671iKJU5fLeRw=; b=f9+yP51LljTXH5woJn37oUeiWq8DcZM5ch+CRD6ykGVaYviijY316GO+d1uKsZFB9H /aNBz3Xvp7e5aC0FypevogiCri1ryhzzoIgAv2kOUBuc2iech2Jpw4F/ncqvdhoYWygt a+rnkYqwVt1zAt0DYhAB0/aftllXndOU+U1dDorM6W9VSBic+xgeCk+q8FahhZN86kbm M6xFNOQSNOcT3v1wdjKCgGQCx4V0MXBXtU0ForXcTpjTGFfiG6DsYhdzx4tdYxEVrlBt obZ/2uQKP5Hhf7bBhr45nllEodoRpTDLtZxSow7w3SaTUNMqqSF8UylpR57+BoVhKDSL CxVg== |
| X-Gm-Message-State | AOPr4FVRVoTKJjHj+MfQz/ybrsMNiMc1t03NTtchxHviZXAFZT7x9VpwtLXUfscKfR41OA== |
| X-Received | by 10.194.93.2 with SMTP id cq2mr28322531wjb.151.1463351525326; Sun, 15 May 2016 15:32:05 -0700 (PDT) |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.7.0 |
| In-Reply-To | <CAPTjJmp1H99HKmEarskE1b-ia0=KFDBTpfU+cWt6vVFeJtBHZg@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| 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> |
| X-Mailman-Original-Message-ID | <5738F8E2.1030403@gmail.com> |
| X-Mailman-Original-References | <57389A9D.1010205@gmail.com> <CAPTjJmp1H99HKmEarskE1b-ia0=KFDBTpfU+cWt6vVFeJtBHZg@mail.gmail.com> |
| Xref | csiph.com comp.lang.python:108648 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 16/05/2016 12:08 πμ, Chris Angelico wrote:
> On Mon, May 16, 2016 at 1:49 AM, Pavlos Parissis
> <pavlos.parissis@gmail.com> wrote:
>> I use subprocess.check_output like this:
>>
>> cmd = [
>> '/sbin/ip',
>> 'address',
>> 'show',
>> 'dev',
>> "{}".format(self.config['interface']),
>> 'to',
>> "{}".format(self.config['ip_prefix']),
>> ]
>
> Unrelated to your problem: "{}".format(x) is the same as str(x), and
> if x is already a string, it does exactly nothing. Most likely you can
> just put your configs straight in there.
>
Thanks for the tip, I will change it as you suggested.
>> try:
>> out = subprocess.check_output(
>> cmd,
>> universal_newlines=True,
>> timeout=1)
>> 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=11
>> encoding='UTF-8'>
>
> Searching the CPython sources for that exception shows one hit:
> selectors.py, where it converts a file object to an integer file
> descriptor. (You could have helped out by showing us the full
> traceback.)
I did, https://gist.github.com/unixsurfer/67db620d87f667423f6f6e3a04e0bff5
> Is it possible you were running out of file descriptors,
> or in some other way unable to create the pipe?
I don't think as I see right now only 8 FDs:
sudo ls -1 /proc/22706/fd|wc
8 8 16
Thanks,
Pavlos
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: intermittent ValueErrors from subprocess Pavlos Parissis <pavlos.parissis@gmail.com> - 2016-05-16 00:32 +0200
csiph-web