Преглед изворни кода

Guard shortcut script with 'if __name__ == __main__' to avoid side-effects when using multiprocessing

Johannes Baiter пре 11 година
родитељ
комит
313f458696
1 измењених фајлова са 3 додато и 2 уклоњено
  1. 3 2
      nsist/__init__.py

+ 3 - 2
nsist/__init__.py

@@ -165,8 +165,9 @@ if appdata:
 
 {extra_preamble}
 
-from {module} import {func}
-{func}()
+if __name__ == '__main__':
+    from {module} import {func}
+    {func}()
 """
     
     def write_script(self, entrypt, target, extra_preamble=''):