intermittent ValueErrors from subprocess

Chris Angelico rosuav at gmail.com
Sun May 15 19:32:37 EDT 2016


On Mon, May 16, 2016 at 9:17 AM, Pavlos Parissis
<pavlos.parissis at gmail.com> wrote:
> On 16/05/2016 12:59 πμ, Chris Angelico wrote:
>> Ah. I didn't click that link in your original post - didn't know it
>> was the traceback. Better would have been to at least say so; best
>> would have been to include it inline.
>>
>
> I don't usually include traces as they have long lines and several
> e-mail clients mess with them in a way that makes the trace unreadable.

If your client can't send them, fix your client. If someone else's
client can't read them, that's not your problem.

>> If you can recreate the problem consistently,
>
> I can't. This is my main problem. This code has been executed ~100K and
> that exception has occurred only ~5 times.

Yeah, I figured. Makes it tough.

>> it would be worth
>> messing around with slightly lower level APIs - using subprocess.Popen
>> rather than check_output, for instance - and see what you can do
>> without the pipes.
>
> What do you mean by that?

You're currently using a very high level API that says "run this
program, make sure it exits zero, and give me its output". Somewhere
inside there, something's going wrong. So the first thing I'd do would
be to tease apart the job into smaller and simpler parts; that means,
in this case, going to something like subprocess.Popen, with explicit
use of pipes and such. You could look at the source code for
check_output for a start.

But being unable to recreate the problem on demand makes it hard.

ChrisA



More information about the Python-list mailing list