[Tutor] subprocess.call warning
Steven D'Aprano
steve at pearwood.info
Mon Oct 4 00:47:11 CEST 2010
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.
> 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?
What does get_abspath do? It sounds like it *may* be your own version of
os.path.abspath.
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".
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
More information about the Tutor
mailing list