Oct-29-2022, 08:08 AM
(This post was last modified: Oct-29-2022, 08:08 AM by Gribouillis.)
(Oct-28-2022, 11:27 PM)Skaperen Wrote: the question is, what way would you like to have your code get this data?The way you describe the problem, it it clear that the subprocess' stdout becomes a source of data that must be read as soon as it is available, so the following should work
- Create an instance of selectors.DefaultSelector and register EVENT_READ for the subprocess' stdout in this instance.
- Call the select() method, which returns a real time sequence of when data has been produced by the subprocess. For each event in the sequence, invoke a callback that reads in the subprocess stdout and attach a time information to the data by calling for example time.perf_counter().
- If the program needs to do something else at the same time, create a thread devoted to reading the subprocess' output. Clearly the thread that receives the data must not do anything else, otherwise the time information will be damaged.