Stdout get updated every 0.5 seconds for every two lines to contain: 0Īnd each log file contains the respective log for a given process. T2 = threading.Thread(target=output_reader, args=(proc2, file2)) For more advanced use cases, the underlying. T1 = threading.Thread(target=output_reader, args=(proc1, file1)) The recommended approach to invoking subprocesses is to use the run() function for all use cases it can handle. Subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc2, \ With subprocess.Popen(, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc1, \ The threading module allows us to do that.įirst, have a look at how to do the output redirection part alone in this question: Python Popen: Write to stdout AND log file simultaneously For example, I wanted to launch two processes that talk over a port between them, and save their stdout to a log file and stdout. Make it executable using the command, chmod x test.py Use no hangup to run the program in the background even if you close your terminal, nohup /path/to/test.py
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |