本文整理汇总了Python中Server.Server.suspend方法的典型用法代码示例。如果您正苦于以下问题:Python Server.suspend方法的具体用法?Python Server.suspend怎么用?Python Server.suspend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Server
的用法示例。
在下文中一共展示了Server.suspend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Simulator
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import suspend [as 别名]
#.........这里部分代码省略.........
self.server.put(event.instance)
elif event.instance.type == Instance.HARD:
self.waiting.put(event.instance, event.instance.priority)
# Compute the next arrival
self.events.put(event.instance.task.nextArrival(event.time))
def reactFinish(self, event):
# Remove the instance from its waiting list
if event.instance.type == Instance.SOFT:
self.server.pop()
elif event.instance.type == Instance.HARD:
self.waiting.pop()
# Compute statistics
if self.stats :
event.instance.statistics()
self.write_instance(event.instance)
# Compute rendering
if self.render :
task = event.instance.task
if not task.id in self.render_data:
self.render_data[task.id] = dict()
self.render_data[task.id]["executed"] = list()
self.render_data[task.id]["arrivals"] = list()
for t in event.instance.executed:
self.render_data[task.id]["executed"].append(t)
self.render_data[task.id]["arrivals"].append(event.instance.arrival)
def reactSuspend(self, event):
# Suspend the server
self.server.suspend()
def reactRefill(self, event):
# Refill the server
self.server.refill()
self.events.put(self.server.nextRefill(event.time))
def read(self, filename):
"""
Load a configuration from a file.
"""
r = ReadConfig()
r.read(filename)
self.server = r.server
self.tasks = r.tasks
def init(self, until = -1):
"""
Initialize the server to run until the given time.
If -1 is given, run until the LCM of periodic tasks.
"""
logging.debug("Initialization until " + str(until))
if (until == -1):
until = PeriodicTask.lcm(self.tasks)
for t in self.tasks:
self.events.put(t.nextArrival(0));
self.events.put(self.server.nextRefill(0))