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


Groups > comp.lang.python > #108639 > unrolled thread

intermittent ValueErrors from subprocess

Started byPavlos Parissis <pavlos.parissis@gmail.com>
First post2016-05-15 17:49 +0200
Last post2016-05-15 17:49 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  intermittent ValueErrors from subprocess Pavlos Parissis <pavlos.parissis@gmail.com> - 2016-05-15 17:49 +0200

#108639 — intermittent ValueErrors from subprocess

FromPavlos Parissis <pavlos.parissis@gmail.com>
Date2016-05-15 17:49 +0200
Subjectintermittent ValueErrors from subprocess
Message-ID<mailman.32.1463327394.2226.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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 = [
    '/sbin/ip',
    'address',
    'show',
    'dev',
    "{}".format(self.config['interface']),
    'to',
    "{}".format(self.config['ip_prefix']),
]

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'>

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_healthchecker/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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web