Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the process to run sub-process with pipes that connect both input and output?

Answers were Sorted based on User's Feedback



What is the process to run sub-process with pipes that connect both input and output?..

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

What is the process to run sub-process with pipes that connect both input and output?..

Answer / siva kumar reddy dandu

try to use subprocess module
x = subprocess.popen(command)
x.read()

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Explain me what are the key features of python?

0 Answers  


Why are we using self as first argument?

0 Answers  


How do you clear a python shell?

0 Answers  


How many types of operators python has?

0 Answers  


Tell me what flask is and its benefits?

0 Answers  


What are tuples and relation?

0 Answers  


In python,how to read a file line-by-line into a list?

0 Answers  


How type casting is done in python?

0 Answers  


Explain Python packages.

3 Answers  


Why does delegation performed in Python?

1 Answers  


Differentiate between the append() and extend() methods of a list?

0 Answers  


What is the difference between old style and new style classes in python?

0 Answers  


Categories