multiscale / muscle3

The third major version of the MUltiScale Coupling Library and Environment
Apache License 2.0
25 stars 13 forks source link

All-in-one-Python-script use case needs guard around top-level code on platforms that spawn #124

Closed LourensVeen closed 1 year ago

LourensVeen commented 2 years ago

In the all-in-one-Python-script use case, we have some top-level driver code that sets up the simulation and then calls runner.run_simulation(). The latter creates a new process for each required instance. On GNU/Linux, that forks, but on MacOS and possibly Windows, it spawns. Spawning starts a new Python interpreter, which loads all the modules, and that executes the top-level code again. The interpreter catches this, and crashes with an error message.

This isn't a bug in MUSCLE3 per se, but we should check that the examples all have an if __name__ == '__main__' around that top level code, and add a comment telling users not to remove it and why.

LourensVeen commented 1 year ago

The examples in MUSCLE3 are all fine, it's actually an issue in the coupled_model.py script used in the course.