Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #108648
| From | Pavlos Parissis <pavlos.parissis@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: intermittent ValueErrors from subprocess |
| Date | 2016-05-16 00:32 +0200 |
| 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> |
[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