@dawkot, unfortunately your implementation has a big performance flaw.

the sleepAsync 5 creates a minimum bound of 5 ms on the execution time + the 
time it takes to run through the event loop. It's the naive solution to the 
problem.

The more correct way to accomplish this with async is to register the file 
handle for stdout of the forked process with the asyncdispatch epoll handler.

There really should be a 'asyncExecProcess` proc in the std lib. Unfortunately 
this does not exist in the std lib at the moment.

There is an excellent third party library that does have a good implementation 
of this. @cheatface's aysnc tools: 
[https://github.com/cheatfate/asynctools/blob/master/asynctools/asyncproc.nim#L122](https://github.com/cheatfate/asynctools/blob/master/asynctools/asyncproc.nim#L122)

For @OldhamMade's usecase, I'm not sure all the extra machinery of async is 
necessary. The difference between Threads vs. Async does not make much of a 
difference for this use case, and the spawn solution is much less code to get 
something that _just works(tm)_.

Reply via email to