nicky van foreest
2011-07-15 18:44:26 UTC
Hi,
I ran into a RuntimeError: maximum recursion depth exceeded in cmp
with Trellis in this (simple) piece of code. I use it to compute the
arrival time, waiting time, etc, for a set of jobs in a simulation.
(These jobs are served on a single server.)
from peak.events import trellis
class Job(trellis.Component):
trellis.attrs(
a = 0, # interarrival time (to previous job)
b = 0, # processing time
)
def __init__(self, a, b, prev = None):
self.a = a
self.b = b
self.prev = prev
def __repr__(self):
ret = str(self.a) + " "
ret += str(self.b) + " "
ret += str(self.arTime) + " "
ret += str(self.waitTime) + " "
ret += str(self.sojourn) + " "
return ret
trellis.compute.attrs(
arTime = lambda self: self.prev.arTime + self.a if self.prev else 0,
waitTime = lambda self: max(self.prev.sojourn - self.a if
self.prev else 0, 0),
sojourn = lambda self: self.waitTime + self.b
)
prev = Job(0,4)
sim = [prev]
for i in range(30):
nxt = Job(1,8,prev)
sim.append(nxt)
prev = nxt
for j in sim:
print j
I think I can repair this by resetting the recursion depth. However, I
suppose this will not work if I run a simulation with a 10e6 jobs. Why
actually does trellis run into this problem? It makes me a bit
suspicious about the scaleability of trellis, or should I not worry
about this?
thanks for any hints.
Nicky
I ran into a RuntimeError: maximum recursion depth exceeded in cmp
with Trellis in this (simple) piece of code. I use it to compute the
arrival time, waiting time, etc, for a set of jobs in a simulation.
(These jobs are served on a single server.)
from peak.events import trellis
class Job(trellis.Component):
trellis.attrs(
a = 0, # interarrival time (to previous job)
b = 0, # processing time
)
def __init__(self, a, b, prev = None):
self.a = a
self.b = b
self.prev = prev
def __repr__(self):
ret = str(self.a) + " "
ret += str(self.b) + " "
ret += str(self.arTime) + " "
ret += str(self.waitTime) + " "
ret += str(self.sojourn) + " "
return ret
trellis.compute.attrs(
arTime = lambda self: self.prev.arTime + self.a if self.prev else 0,
waitTime = lambda self: max(self.prev.sojourn - self.a if
self.prev else 0, 0),
sojourn = lambda self: self.waitTime + self.b
)
prev = Job(0,4)
sim = [prev]
for i in range(30):
nxt = Job(1,8,prev)
sim.append(nxt)
prev = nxt
for j in sim:
print j
I think I can repair this by resetting the recursion depth. However, I
suppose this will not work if I run a simulation with a 10e6 jobs. Why
actually does trellis run into this problem? It makes me a bit
suspicious about the scaleability of trellis, or should I not worry
about this?
thanks for any hints.
Nicky