Przeglądaj źródła

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

Johannes Baiter 11 lat temu
rodzic
commit
313f458696
1 zmienionych plików z 3 dodań i 2 usunięć
  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=''):