On 2013-01-04 02:18 +0800, Ben Darnell wrote:
> autoreload is actually smart about syntax errors when run as a wrapper
> like this - it will still catch the error and wait for the next change
> to re-run the tests, so you shouldn't need an outside loop. When
> autoreload is used in other ways (i.e. Application(debug=True)), it
> can't recover from syntax errors because they often occur before the
> IOLoop gets started. This means it's useful to use both modes of
> autoreload at once: "python -m tornado.autoreload -m
> myproject.server.main --debug". The --debug flag (which gets passed to
> the Application settings) will handle reloads while the server is
> running, and the outer "-m tornado.autoreload" catches syntax errors
> and other startup problems.
>
> -Ben
In some cases, it works like described above. But not always.
python -m tornado.autoreload t.py
If I introduce a syntax error in s.py the shell session looks like this:
$ python -m tornado.autoreload t.py
Hello, I am S.
I am T.
Hello, I am S.
WARNING:root:Script exited with uncaught exception
Traceback (most recent call last):
File "/Users/leo/python/lib/python2.7/site-packages/tornado/autoreload.py", line 273, in main
exec f.read() in globals(), globals()
File "<string>", line 1, in <module>
File "/Users/leo/sandbox/s.py", line 2, in <module>
z
NameError: name 'z' is not defined
........
after this point whatever changes made to s.py, tornado is not
restarting the script.