I want to make simulation where the service time depends on computation complexity of some function.
The request arrival should not stop due to the function processing. For testing I use example function that utilizes cpu for some seconds:
sorted([float(random.random()) for i in range(1000000)])
How can I call it to simulate service, but do not prevent new service request arrival. If I call this function, new service request arrives just after function execution, not at the stated time.
def visit(self, timeAtNAT, res):
arrive=time.clock()-startTime
print("%7.4f. Packet #%s arrived." % (time.clock()-startTime, self.name))
yield request, self, res
wait = time.clock()-startTime - arrive
print("%7.4f. Packet #%s waited %6.3f" % (time.clock()-startTime, self.name, wait))
sorted([float(random.random()) for i in range(1000000)])
yield release, self, res
print("%7.4f. Packet #%s left" % (time.clock()-startTime, self.name))
So, in my example new Packet arrives only after previous packet was left.
I tried to use multiprocessing
, but I got naming collision (of Process
class).
I am novice in SimPy, parallel programming and Python.