-1

I am trying to write a program for process communication using Python and SimPy. If I put all code in a single function and call

simpy.Environment().process(function_one())

everything runs perfectly. However, if I call another function within function_one() like

def function_one(self):
  function_two()

function_two will never be executed. function_two will be executed if I call it like this

def function_one(self):
  simpy.Environment().process(function_two())

However, the rest of function_one will then executed and won't wait for function_two to execute. I obviously don't want to put all of my code in one function so any help would be appreciated.

wir963
  • 181
  • 1
  • 9

1 Answers1

1

Functions passed to process() have to be generator functions yielding event instances. Furthermore, you have to call Environment.run() in order to actually execute the simulation. You should read the tutorial to get started with SimPy.

Stefan Scherfke
  • 3,012
  • 1
  • 19
  • 28