]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Make "python -m tornado.autoreload" run with a consistent sys.path.
authorBen Darnell <ben@bendarnell.com>
Tue, 19 Jul 2011 04:25:59 +0000 (21:25 -0700)
committerBen Darnell <ben@bendarnell.com>
Tue, 19 Jul 2011 04:25:59 +0000 (21:25 -0700)
tornado/autoreload.py

index b34ace8859d0e8894a3ca018fce5e59e4f135449..7c3ddb5cf747b3445b49274daf0a0c747a7745d7 100644 (file)
@@ -197,4 +197,12 @@ def main():
     
 
 if __name__ == "__main__":
+    # If this module is run with "python -m tornado.autoreload", the current
+    # directory is automatically prepended to sys.path, but not if it is
+    # run as "path/to/tornado/autoreload.py".  The processing for "-m" rewrites
+    # the former to the latter, so subsequent executions won't have the same
+    # path as the original.  Modify os.environ here to ensure that the
+    # re-executed process will have the same path.
+    if sys.path[0] == '':
+        os.environ["PYTHONPATH"] = ".:" + os.environ.get("PYTHONPATH", "")
     main()