Closed kavithabhaskaran closed 9 years ago
Looks like a very popular error https://github.com/Clearskyabove/zurb-foundation.docpad/issues/2 - But I am not able to figure out what is causing it exactly since I am not specifically using Grunt..
I was able to resolve it locally by changing all "Popen()" calls with "call()" but I still do not understand why I would get a JS error..
I edited your original post to make it more readable.
The reason it crashes, as far as I can think is contention around the descriptors while both the python script and canned want to write to stdout
. It seems like node is not failing gracefully in this case by just waiting for the this to become available but dies when it fails to write, it could also be the case that python does not hand over the descriptor correctly. Since call
actually blocks for the program to finish there is no contention and everything works. This is just a guess as I don't know how I can verify it but this is what seems to be happening, I don't think there is anything I can do from the canned side I think.
In case people are still running into this, here's how I solved it. Basically, if I didn't set a STDIN/STDOUT/STDERR for the Popen call, it seemed to work.
Startup.POPEN_CANNED = subprocess.Popen(['canned -p 3000 %s' % props.mockBase], shell=True, preexec_fn=os.setsid)
The POPEN_CANNED variable is just a static class variable to the returned Popen so that I can shutdown canned later with:
Startup.POPEN_CANNED.terminate()
Startup.POPEN_CANNED.wait()
Hope that helps.
Awesome thanks for the tip! I added it to the wiki.
Hi Phil:
I have 2 scenarios here:
Scenario #1 (Works fine).
When I start canned API server on Python >> (Python CLI prompt)
and run the "python add.py" (which does a curl POST) on regular $ prompt, everything works fine and dandy as expected.
Values of Controller IDs and Controller Names that were successfully added.
Scenario #2.(Canned Server crashes and js error)
When I run both startServer script and add.py from python interactive mode,
Values of Controller IDs and Controller Names that were successfully added.
As you have seen, Scenario #2 also works but after 4-5 seconds, I get the error message (which I presume if from Canned) and the Canned server crashes. Would you know why it would crash??
Just to clarify, the "add.py" does this :