INCF / MUSIC

MUSIC, the MUltiSimulation Coordinator
GNU General Public License v3.0
37 stars 37 forks source link

music.Setup() fails if nest is imported #70

Open cristianoalessandro opened 3 years ago

cristianoalessandro commented 3 years ago

Hi all,

I recently found this issue. If nest is imported, music.Setup() complains that Setup constructor was already called.

#!/usr/bin/env python3

import music
import nest

import ctypes
ctypes.CDLL("libmpi.so", mode=ctypes.RTLD_GLOBAL)

setup = music.Setup()

running this simple code throws the error:

Error in MUSIC library: rank #0: Setup constructor was called a second time.
Only one Setup object can exist at any instance of time.

This is independent of the order of the two imports, and the issue disappears by commenting out import nest.

mdjurfeldt commented 3 years ago

Right, but this is, at least almost, a feature.

As a MUSIC-aware application, NEST controls MUSIC. For example, it controls when switching to the Runtime phase and it calls the MUSIC tick() in its simulation loop.

By importing the MUSIC Python bindings, you indicate that you intend to do something similar.

Please explain what it is that you want to do in this script. If it is something reasonable, we might be able to provide novel MUSIC support for it.

cristianoalessandro commented 3 years ago

I would like to import a module I wrote that has also some NEST-related functionality, and therefore in turn imports nest. I cannot import my module though because I run into the indicated issue.

Best Cristiano

On Tue, Mar 23, 2021 at 7:11 PM mdjurfeldt @.***> wrote:

Right, but this is, at least almost, a feature.

As a MUSIC-aware application, NEST controls MUSIC. For example, it controls when switching to the Runtime phase and it calls the MUSIC tick() in its simulation loop.

By importing the MUSIC Python bindings, you indicate that you intend to do something similar.

Please explain what it is that you want to do in this script. If it is something reasonable, we might be able to provide novel MUSIC support for it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/INCF/MUSIC/issues/70#issuecomment-805120311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJNSRLAGGGFLJIWCC5FKXLDTFDKWBANCNFSM4ZVVCWQQ .