wright-group / WrightSim

A simulation package for multidimensional spectroscopy.
MIT License
4 stars 0 forks source link

RunTime error with mp='cpu' #41

Closed kameyer226 closed 4 years ago

kameyer226 commented 4 years ago

RunTime Error reported with target.py, changing expression in exp.run with above flag, as follows:

RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.RuntimeError:
    An attempt has been made to start a new process before the
    current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.
ksunden commented 4 years ago

Try putting

if __name__ == "__main__":

In target.py (after imports and such, and indent the remainder of the file, most importantly with the exp.run line in the indented portion)

kameyer226 commented 4 years ago

It now works. Freeze_support not tested.

ksunden commented 4 years ago

https://docs.python.org/3/library/multiprocessing.html#multiprocessing.freeze_support

freeze_support does nothing unless we are packaging into a standalone exe