Benjamin Watine wrote:
> OK, so if I understand well what you said, using queue allow to be sure
> that the data is passed in totality before coninuing with next
> instruction. That make sense.
Right.
> Using thread and queue seems to be very more slow than using files
> redirection with bash.
Bryan Olson a écrit :
> Benjamin Watine wrote:
>> [EMAIL PROTECTED] a écrit :
>>> I wrote:
And here's a thread example, based on Benjamin's code:
>>> [...]
>>>
>>> Doh! Race condition. Make that:
>>>
>>> import subprocess
>>> import thread
>>> import Queue
>>>
>>> def readtoq(p
Benjamin Watine wrote:
> [EMAIL PROTECTED] a écrit :
>> I wrote:
>>> And here's a thread example, based on Benjamin's code:
>> [...]
>>
>> Doh! Race condition. Make that:
>>
>> import subprocess
>> import thread
>> import Queue
>>
>> def readtoq(pipe, q):
>> q.put(pipe.read(
[EMAIL PROTECTED] a écrit :
> I wrote:
>> And here's a thread example, based on Benjamin's code:
> [...]
>
> Doh! Race condition. Make that:
>
> import subprocess
> import thread
> import Queue
>
> def readtoq(pipe, q):
> q.put(pipe.read())
>
> cat = subprocess.Popen
I wrote:
> And here's a thread example, based on Benjamin's code:
[...]
Doh! Race condition. Make that:
import subprocess
import thread
import Queue
def readtoq(pipe, q):
q.put(pipe.read())
cat = subprocess.Popen('cat', shell=True, stdin=subprocess.PIPE,
stdout=subpr
Floris Bruynooghe wrote:
> Benjamin Watine wrote:
> > Could you give me more information / examples about the two solutions
> > you've proposed (thread or asynchronous I/O) ?
>
> The source code of the subprocess module shows how to do it with
> select IIRC. Look at the implementation of the commu
On Mar 14, 11:37 am, Benjamin Watine <[EMAIL PROTECTED]> wrote:
> Bryan Olson a écrit :
>
> > I wrote:
> >> [...] Pipe loops are tricky business.
>
> >> Popular solutions are to make either the input or output stream
> >> a disk file, or to create another thread (or process) to be an
> >> active re
Bryan Olson a écrit :
> I wrote:
>> [...] Pipe loops are tricky business.
>>
>> Popular solutions are to make either the input or output stream
>> a disk file, or to create another thread (or process) to be an
>> active reader or writer.
>
> Or asynchronous I/O. On Unix-like systems, you can selec
I wrote:
> [...] Pipe loops are tricky business.
>
> Popular solutions are to make either the input or output stream
> a disk file, or to create another thread (or process) to be an
> active reader or writer.
Or asynchronous I/O. On Unix-like systems, you can select() on
the underlying file descr
Benjamin Watine wrote:
> And if somebody need it : to get the stdout in a var (myNewVar), not in
> the shell :
>
> cat = subprocess.Popen('cat', shell = True, stdin = subprocess.PIPE,
> stdout=subprocess.PIPE)
> cat.stdin.write(myVar)
> cat.stdin.close()
> cat.wait()
> myNewVar = cat.stdout.read
Marko Rauhamaa a écrit :
> Benjamin Watine <[EMAIL PROTECTED]>:
>
>> How can I do this ? I would like a function like that :
>>
>> theFunction ('cat -', stdin=myVar)
>>
>> Another related question : Is there's a limitation of var size ? I
>> would have var up to 10 MB.
>
> import subprocess
Benjamin Watine <[EMAIL PROTECTED]> wrote:
>How can I do this ? I would like a function like that :
>
> theFunction ('cat -', stdin=myVar)
>
>I don't need to get any return value.
http://docs.python.org/lib/node534.html says this is spelt
myVar = subprocess.Popen(["cat", "-"], stdout=subpr
Benjamin Watine <[EMAIL PROTECTED]>:
> How can I do this ? I would like a function like that :
>
> theFunction ('cat -', stdin=myVar)
>
> Another related question : Is there's a limitation of var size ? I
> would have var up to 10 MB.
import subprocess
myVar = '*' * 1000
cat = subproce
13 matches
Mail list logo