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
signature.asc
Description: OpenPGP digital signature
-- https://mail.python.org/mailman/listinfo/python-list