3

I am currently working on a random characters generator which use multiprocessing to accelerate the process. I use

if __name__ == "__main__":

to avoid the whole code to run multiple time, but whenever I use auto py to exe to compile it and run it, it just runs the code multiple times.

How could I avoid that?

Thanks!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Juloup 78
  • 31
  • 4
  • 1
    did you call [`multiprocessing.freeze_support()`](https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support) directly after `if __name__ == "__main__"`? – Aaron Mar 21 '22 at 15:00
  • no, i did not. what does it do ? – Juloup 78 Mar 21 '22 at 15:33
  • 1
    It is required for "freezing" your script to an executable (on Windows). IIRC it fixes the way command line args are passed to the child processes so they don't think they are also "main" – Aaron Mar 21 '22 at 15:34

0 Answers0