![]() ![]() In order to avoid the two outputs becoming Their input and outputs since we have two inputs and outputs and only one mother This is necessary because we want to have control over Note that both our subprocesses are opened with their stdins and stdoutsįrom internal pipes. ![]() ![]() PIPE) while True: # check if either sub-process has finished proc_a. # two_subprocesses.py import subprocess # start both `proc_a.py` and `proc_b.py` proc_a = subprocess. Prompt, reading a line of input, echoing that back and prompting for more input: Going to spawn will be kept very simple, doing nothing more than printing a The Two Sub-ProcessesĪs an illustration of what can be achieved, the two sub-processes that we are Which output comes from which process we’ll prepend output from process A withĪn A: and from process B with a B. Of the processes will be printed on stdout, but to enable us to differentiate These two pipes A and B will read their respective inputs. What we aim to end up with is a program that starts up two sub-processes, let’sĬall them A and B, and connects to two named pipes in the file system. The server, to provide a set of pre-scripted commands to each to get them in aĬertain state, and then a way of providing my own custom commands, to do some Basically, I wanted a program to start up the client and In this section we’ll do the same, but this time for two sub-processes.Ī use for this, and the original reason I first developed this, was for testingĪ client and server. We explored start a subprocess and controlling its input and output via ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |