diff --git a/tornado/autoreload.py b/tornado/autoreload.py index ad6cec3660..da1b100d7e 100644 --- a/tornado/autoreload.py +++ b/tornado/autoreload.py @@ -217,19 +217,20 @@ def _reload(): # $PYTHONPATH. spec = getattr(sys.modules['__main__'], '__spec__', None) if spec: - sys.argv = ['-m', spec.name] + sys.argv[1:] + argv = ['-m', spec.name] + sys.argv[1:] else: + argv = sys.argv path_prefix = '.' + os.pathsep if (sys.path[0] == '' and not os.environ.get("PYTHONPATH", "").startswith(path_prefix)): os.environ["PYTHONPATH"] = (path_prefix + os.environ.get("PYTHONPATH", "")) if not _has_execv: - subprocess.Popen([sys.executable] + sys.argv) + subprocess.Popen([sys.executable] + argv) sys.exit(0) else: try: - os.execv(sys.executable, [sys.executable] + sys.argv) + os.execv(sys.executable, [sys.executable] + argv) except OSError: # Mac OS X versions prior to 10.6 do not support execv in # a process that contains multiple threads. Instead of @@ -242,8 +243,7 @@ def _reload(): # Unfortunately the errno returned in this case does not # appear to be consistent, so we can't easily check for # this error specifically. - os.spawnv(os.P_NOWAIT, sys.executable, - [sys.executable] + sys.argv) + os.spawnv(os.P_NOWAIT, sys.executable, [sys.executable] + argv) # At this point the IOLoop has been closed and finally # blocks will experience errors if we allow the stack to # unwind, so just exit uncleanly. diff --git a/tornado/test/import_test.py b/tornado/test/import_test.py index e5eaec332b..88d02e0270 100644 --- a/tornado/test/import_test.py +++ b/tornado/test/import_test.py @@ -9,6 +9,7 @@ def test_import_everything(self): # all (unless they have external dependencies) here to at # least ensure that there are no syntax errors. import tornado.auth + import tornado.autoreload import tornado.concurrent import tornado.escape import tornado.gen