wouldn't calling communicate only if retcode is non-zero would be "too late"? i.e. we first should have to have Popen redirecting to pipes.  also those would require additional threads while communicate'ing -- and we have already so many ;)

I wondered -- may be it would be worth to create/use a temporary file which would be provided as stdout/stderr and thus collect all the output... that would prevent anything dumped to the screen, and it could then be read back in case of 'debug' level and failure... somewhat ugly but should avoid any additional threading, buffers locking , etc... and since we lock for execution of the command -- should be thread safe to re-use a single file for that purpose... what do you think?