[PATCH] util: simplify pipefilter and avoid subprocess race
Martin Geisler
mg at lazybytes.net
Thu May 7 03:38:58 CDT 2009
Greg Ward <greg-hg at gerg.ca> writes:
> On Wed, May 6, 2009 at 6:23 PM, Martin Geisler <mg at daimi.au.dk> wrote:
>> # HG changeset patch
>> # User Martin Geisler <mg at lazybytes.net>
>> # Date 1241648562 -7200
>> # Node ID ea3ec68a61808013de543ea306da939c7146287e
>> # Parent b0ce2595777bddf8d4a62119e3a2dfb8ca0078b4
>> util: simplify pipefilter and avoid subprocess race
>>
>> The subprocess module is not thread safe. Spawning a thread to read
>> the output leads to exceptions like this when Mercurial exits:
> [...]
>> + p = subprocess.Popen(cmd, shell=True, close_fds=closefds,
>> + stdin=subprocess.PIPE, stdout=subprocess.PIPE)
>> + pout, perr = p.communicate(s)
>> + return pout
>
> But who wait()s on the subprocess?
In this case the communicate method does -- the documentation says:
Interact with process: Send data to stdin. Read data from stdout and
stderr, until end-of-file is reached. *Wait for process to terminate.*
The optional input argument should be a string to be sent to the
child process, or None, if no data should be sent to the child.
So I think we're okay here.
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
More information about the Mercurial-devel
mailing list