Explorar o código

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

Johannes Baiter %!s(int64=11) %!d(string=hai) anos
pai
achega
313f458696
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  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=''):