What is the process to run sub-process with pipes that connect both input and output?
Answers were Sorted based on User's Feedback
Answer / chaitanya
The popen2() module is used to run the sub-process but due to some difficulty in processing like creation of deadlock that keep a process blocked that wait for the output from the child and child is waiting for the input. The dead lock occurs due to the fact that parent and child doesn’t have the synchronization and both are waiting to get the processor to provide the resources to one another. Use of popen3() method allow the reading of stdout and stderr to take place where the internal buffer increases and there is no read() takes place to share the resources. popen2() take care of the deadlock by providing the methods like wait() and waitpid() that finishes a process first and when a request comes it hands over the responsibility to the process that is waiting for the resources. The program is used to show the process and run it.
import popen2
fromchild, tochild = popen2.popen2("command")
tochild.write("input
")
tochild.flush()
output = fromchild.readline()
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / siva kumar reddy dandu
try to use subprocess module
x = subprocess.popen(command)
x.read()
| Is This Answer Correct ? | 0 Yes | 0 No |
What does the 'yield' keyword do in python?
Can you hack with python?
What is the usage of help() function in python?
Is pypy faster than python?
How long does it take to learn python?
In python, how you can randomize the items of a list in place ?
What is type conversion in python?
What is the procedure to extract values from the object used in python?
Does python have oops concepts?
What do you mean by instance?
Is python good for windows?
Given a text file (FILE1) with lots of words (ex, an ebook), and another file (FILE2) with a list of blacklist words (slangs, porn, etc.), write a program to find the top 100 words(most frequent 100 words) from FILE1 which are not present in FILE2.