2.4isms for bzr
John A Meinel
john at arbash-meinel.com
Tue Jul 26 18:46:24 BST 2005
Aaron Bentley wrote:
> John A Meinel wrote:
>
>>>I agree that having communicate be one time is a little bit of a pain,
>>>but I think it is for simplicity, and the fact that a lot of times, that
>>>is all you need.
>
>
> Sure, it's just that everyone says subprocess is the greatest thing
> since sliced wheels, and this seems like an oversight.
Mmmmm, sliced wheels, droool. :)
Actually, subprocess is a vast improvement over all of the popen
functionality, especially if you want cross platform compatiblility
(since the Popen3,4 classes don't exist in Windows).
but yes, I have often wished that something like communicate was re-entrant.
>
>
>>>And it depends what you mean by "efficient", because your above code
>>>just buffers everything in ram, which is what communicate does.
>
>
> It doesn't require you to generate one big string for stdin-- it can be
> an iterator, which is more eficient. You can also imagine writing an
> iterator that yields stdout and does something else with stderr. Or
> yields stderr and writes stdout to disk. Endless possibilities for
> efficient handling!
>
>
>>>Heck, make iter_communicate support having input being a generator, and
>>>you could even have bi-directional communications with another process,
>>>while having it only really look like a loop.
>
>
> Exactly the kind of thing I mean. Especially if 2.5 introduces
> iterators with send() (which is under discussion), it would be criminal
> not supporting this mode of operation.
Sure. Hopefully, if 2.5 does handle the re-entrant yield gives a value
iterators, subprocess will be updated to support this.
Certainly their examples show "data = yield nonblocking_read(sock)"
which would be what you want for pipes to do nice ipc.
>
> Aaron
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050726/6c09f629/attachment.pgp
More information about the bazaar
mailing list