"waiting for changes..." not issued when monitoring subprocess in python
quotquot opened this issue · 0 comments
My backend is written in python and, during development, instead of calling 'rollup -w' for each of my many frontend modules, the server starts a rollup-watch subprocess for each frontend module and monitors the subprocess output to be sure to serve the new modules. The problem I'm having is that a build triggered after a file change does not issue any line that could allow me to know that the build is over and that all the bundles are available.
The problem is shown by the following Python code:
import subprocess
proc = subprocess.Popen(['./node_modules/rollup/bin/rollup', '-c', '-w'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
print(proc.stderr.readline().decode('utf8').strip())
If my rollup config file processes two javascript files input1.js and input2.js and generates two files output1.js and output2.js, then the code above will print:
rollup v0.50.0
bundles input1.js → output1.js...
created output1.js in 289ms
bundles input2.js → output2.js...
created output2.js in 44ms
But now if I change and save input1.js, the following lines in the pipe will be:
bundles input1.js → output1.js...
created output1.js in 169ms
What I would need is something like this:
rollup v0.50.0
bundles input1.js → output1.js...
created output1.js in 289ms
bundles input2.js → output2.js...
created output2.js in 44ms
[2017-11-02 14:04:04] waiting for changes...
bundles input1.js → output1.js...
created output1.js in 169ms
[2017-11-02 14:04:53] waiting for changes...
This way, I could know when all my bundles are available.
The "strange" thing is that it works if I don't use pipes. The following code:
import subprocess
proc = subprocess.Popen(['./node_modules/rollup/bin/rollup', '-c', '-w'])
while True:
print(proc.stderr.readline().decode('utf8').strip())
will print the "waiting for changes..." line as usual.
My guess is that it's related to printing to a terminal or not but I have no idea if this can be fixed on my side alone. In all cases, I would expect the monitoring pipes to get the same lines as my terminal. Would it not make sense to write a line in the pipe to notify the end of a successful build?