joshooaj / bgprocess Goto Github PK
View Code? Open in Web Editor NEWStart a process and asynchronously access the STDIO streams
Home Page: https://www.joshooaj.com/BGProcess
License: MIT License
Start a process and asynchronously access the STDIO streams
Home Page: https://www.joshooaj.com/BGProcess
License: MIT License
Currently, all of the StandardError content is returned, followed by all of the StandardOutput content, each as individual strings.
This means the output order is not being preserved, and we can't tell how much time passed between two lines of output.
Instead of returning strings, Read-BGProces
could return a rich object similar to BGProcessRecord
...
enum StdIOStream {
StandardOutput
StandardError
StandardInput
}
class BGProcessRecord {
[int] $PID
[datetime] $Timestamp
[StdIOStream] $Stream
[string] $Content
}
The method of monitoring StandardOutput and StandardError in this module is to read the streams from a separate runspace where, if the read operation blocks, it doesn't have to impact the user's shell.
Another option for reading from these streams is to use 'Register-ObjectEvent' to subscribe to the OutputDataReceived and ErrorDataReceived events.
This could simplify the module a bit, but it looks like the event only fires when a newline is encountered. This means that when an application prompts for input, typically you wouldn't receive the prompt until you blindly write to StandardInput and cause the application to write a newline.
The events also exclusively send string data, so if I want to add binary support to the module the event handlers wouldn't be an option.
Because of these two issues, I'm leaning towards avoiding the event handlers entirely. The only true advantage of using them was being able to interleave stdout and stderr messages accurately, but this can be done in the current implementation with some smarter processing anyway.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.