multiscale / muscle3

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

F_INIT -> O_F loops cause the planner to hang #208

Closed LourensVeen closed 1 year ago

LourensVeen commented 1 year ago

If you make a yMMSL file with two components with F_INIT and O_F ports, and hook them up in a loop, the manager will hang if you try to start it.

ymmsl_version: v0.1

model:
  name: simple_hang

  components:
    a:
      implementation: a
      ports:
        f_init: i
        o_f: o

    b:
      implementation: b
      ports:
        f_init: i
        o_f: o

  conduits:
    a.o: b.i
    b.o: a.i

settings: {}

resources:
  a:
    threads: 1
  b:
    threads: 1

implementations:
   a:
     executable: a
   b:
     executable: b

The problem is in ModelGraph.calc_predecessors() which tries to find a next component to process that has all its predecessors already processed. If there aren't any, it keeps trying.

I think that we need to check at the end of the loop if started and finished are both empty. If that's the case, then nothing has changed, and therefore nothing will change, so we should quit the loop. If there are still items in todo or doing, then we have a loop and should generate an error message.

LourensVeen commented 1 year ago

Released in 0.7.0.