I've noticed an annoying feature of the development mode of pyramid, that is, it's server kills itself if it encounters a syntax error.
While that is certainly safe, what I think it should really do is just try again after the next file change (that usually fixes the syntax error....).
A pull request would be awesome.
Matt Good just made a solution for this for Flask: https://github.com/mgood/flask-failsafe
Daniel Holth also created something a number of moons ago that we might dredge up. I don't have a link to it at the moment.
An attempt at better behavior when reload cannot restart the controll…
…ed application, see issue #681
Anybody have a better idea than the one described by the commit above?
Well, I'm testing this right now.
1) Too much description text.
2) I would rather press ^C and restart manually than change my __init__ file.
3) It doesn't restart when I'm fixing syntaxerror in my views.py file of starter project. But restarts when I'm changing pserve.py! :))
4) When it 'freezes' on files check we don't handle ^C = showing useless traceback.
K, welp, I have no better ideas.
(the above things you described are all expected).
#698 - I'm sorry I don't know how to attach commit to this issue :)
The existing behavior, stopping the server on syntax errors, seems best to me. Sometimes after the error that stops the server, your next editing activity in your code returns it to a state that is runnable (sans syntax problems) but may not yet be ready or safe in some other way. Some of us might not want it actually running again until after a manual restart. Auto-restart after error could be made an option, but how about not default?
Maybe you are better of if you disable auto reloading at in your situation.
Because I would highly doubt that you can even guarantee a high probability that your code gets into situations where you don't want to run it only after you made a change that doesn't let the code compile / load anymore.
That being said, maybe the real solution for you may be to create a separate development environment where software failure does not have harsh consequences.
I see that I can call the development server as pserve --reload --monitor-restart development.ini, but with --monitor-restart the server keeps starting over and over, hogging the CPU. Instead, it would be ideal if it would only attempt the restart when the same files being monitored by --reload change.
pserve --reload --monitor-restart development.ini
Would really be great for development workflow to be able to have the server restart on its own in response to code changes.