私は SimPy 2.3 を使用しており、ATM でランダムなレートで顧客を生成するプロセスと、ランダムなレートで顧客にサービスを提供する別のプロセスがあります。列が空になったら、ATM に次の顧客が来るのを待ってから他のことをしてもらいたいです。
ここにいくつかのコードがあります
class ATM(Process):
def Run(self):
while 1:
if self.atm_line.customers is 0:
yield hold, wait for self.atm_line.customers != 0 # this is the line I'm stuck on
yield hold, self, random.expovariate(.1)
self.atm_line.customers -= 1
class ATM_Line(Process):
def __init__(self):
self.customers = 0
Process.__init__(self)
def Run(self):
while 1:
yield hold, self, random.expovariate(.1)
self.customers += 1
initialize()
a = ATM()
a.atm_line = ATM_Line()
activate(a, a.Run())
activate(a.atm_line, a.atm_line.Run())
simulate(until=10000)
これを行う良い方法は何ですか?