[Tutor] subprocess.call warning

Norman Khine norman at khine.net
Mon Oct 4 08:42:16 CEST 2010


thank you for the reply

On Mon, Oct 4, 2010 at 12:47 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Mon, 4 Oct 2010 06:44:54 am Norman Khine wrote:
>> hello, from the docs http://docs.python.org/library/subprocess.html i
>> see there is a WARNING about deadlock when using the subprocess.call.
>> in my code i have this
>>
>> http://pastie.org/1197024
>
>
> The warning says:
>
>    Like Popen.wait(), this will deadlock when using stdout=PIPE
>    and/or stderr=PIPE and the child process generates enough
>    output to a pipe such that it blocks waiting for the OS pipe
>    buffer to accept more data.
>
> Since you don't set either stdout or stderr to PIPE, you shouldn't have
> to worry about a deadlock.
ah ok
>
>
>> the first calls the 'sox' library which joins all the .wav files into
>> one file and then i use the 'wav2swf' library to create a SWF output
>> of the file.
>>
>> can the code be improved?
>
> Code can always be improved :-) What do you consider an improvement?
> Easy to maintain in the future? Faster? Smaller?

to make it faster.

>
> What does get_abspath do? It sounds like it *may* be your own version of
> os.path.abspath.

i am using the iTools python library
http://docs.hforge.org/itools/web.html#public-api

http://git.hforge.org/?p=itools.git;a=blob;f=core/utils.py

>
> I'm not sure why you have a list called "imgtext" that doesn't contain
> text. It seems to be a list of partial file names rather than "image
> text".

the code is for my own implementation of a captcha to see how python
interacts with system libraries such as SOX and WAV2SWF and of course
to learn.

http://pastie.org/1197919

but yes, it is 'text' so i will change it in the next version.

>
> Your code, as given, can't work, because you call isupper() on integers
> 1 2 and 3. That will fail.
>
> I'd probably prefer to generate the filenames differently:
>
> def fix_filename(fname, base=sound_path):
>    fname = str(fname)
>    if fname.isupper():
>        fname = "upper_%s" % fname.lower()
>    return os.path.join(base, fname + '.wav')
>
> and then call it:
>
> filenames = ['A', 'b', 'c', 'D', 1, 2, 3]
> for name in filenames:
>    name = fix_filename(name)
>    sox_filenames.append(name)
>
>
> --
> Steven D'Aprano
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
˙uʍop ǝpısdn p,uɹnʇ pןɹoʍ ǝɥʇ ǝǝs noʎ 'ʇuǝɯɐן sǝɯıʇ ǝɥʇ puɐ 'ʇuǝʇuoɔ
ǝq s,ʇǝן ʇǝʎ
%>>> "".join( [ {'*':'@','^':'.'}.get(c,None) or
chr(97+(ord(c)-83)%26) for c in ",adym,*)&uzq^zqf" ] )


More information about the Tutor mailing list