本文整理汇总了Python中Server.Server.receive方法的典型用法代码示例。如果您正苦于以下问题:Python Server.receive方法的具体用法?Python Server.receive怎么用?Python Server.receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Server
的用法示例。
在下文中一共展示了Server.receive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import receive [as 别名]
class Scheduler:
ONE_MINUTE = 60
EXP_LEN = 240 # in minutes
INFTY = 9999999
userNetLogFileName = "user_net_lp_5_highload_2_10.log"
logFileName = "all_lp_5_highload_2_10.log"
timer = None
tweetGen = None
server = None
userNodes = None
userNodeNum = 0
isDone = False
userCurNetIn = None
userCurNetOut = None
userAccNetIn = None
userAccNetOut = None
serverCurNetIn = 0
serverCurNetOut = 0
serverSbCurNetOut = 0
msgID = 0
msgRecCnt = 0
msgRecExpCnt = 0
msgPrevRecCnt = 0
msgPrevRecExpCnt = 0
def __init__(self):
self.timer = Timer()
self.tweetGen = TweetGen(self.timer)
self.server = Server(self.timer)
self.userNodes = self.server.get_user_nodes()
self.userNodeNum = len(self.userNodes)
self.userCurNetIn = [0] * self.userNodeNum
self.userCurNetOut = [0] * self.userNodeNum
self.userAccNetIn = [0] * self.userNodeNum
self.userAccNetOut = [0] * self.userNodeNum
def _one_second(self):
"""
1. while tweetGen generate tweet
2. in while put tweet into server's inBuf
3. server send
4. every user receive
5. every user send
"""
self.isDone = self.tweetGen.is_done()
while self.tweetGen.has_next():
tweet = self.tweetGen.next()
#print tweet
#timestamp, folNum, msgLen
self.server.put_to_in_buf(tweet[0], self.msgID, tweet[1], tweet[2])
self.msgID += 1
self.server.receive()
self.server.send()
self.msgRecExpCnt += self.server.get_msg_rec_exp_cnt()
#print self.server.get_cur_net_stat()
for user in self.userNodes:
user.receive()
for user in self.userNodes:
user.send()
for user in self.userNodes:
curNetIn, curNetOut = user.get_cur_net_stat()
self.userCurNetIn[user.id] += curNetIn
self.userCurNetOut[user.id] += curNetOut
for user in self.userNodes:
self.isDone = self.isDone and user.is_done()
if not self.isDone:
break
for user in self.userNodes:
self.msgRecCnt += user.get_new_msg_count()
for user in self.userNodes:
user.rand_fail()
def simulate(self):
cnt = 0
minCnt = 0
self.msgRecCnt = 0
self.msgRecExpCnt = 0
fLog = open(self.logFileName, "w")
while not self.isDone:
if minCnt >= self.EXP_LEN:
break
self._one_second()
#.........这里部分代码省略.........