当前位置: 首页>>代码示例>>Python>>正文


Python Client.stop方法代码示例

本文整理汇总了Python中Client.Client.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Client.stop方法的具体用法?Python Client.stop怎么用?Python Client.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client.Client的用法示例。


在下文中一共展示了Client.stop方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: d_mf

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import stop [as 别名]
def d_mf(comm, wk_comm, local_data, local_P, k, steps=500, alpha=0.0002, beta=0.02):
    zeros = numpy.zeros(k)
    client = Client(comm, wk_comm)
    client.start()
    my_rank = comm.Get_rank()
    for row in local_data:
        client.inc(my_rank, row[1] - 1, zeros)
    local_Q = dict()
    e = 0
    for step in range(steps):
        print('rank %d, iter=%d' % (my_rank, step))
        client.clock(my_rank, e)
        local_Q.clear()
        for row in local_data:
            # 需要减去偏移值
            ii = int(row[0] - local_data[0][0])
            jj = int(row[1] - 1)
            value = float(row[2])
            q = local_Q.get(jj)
            if q is None:
                q = local_Q[jj] = client.pull(my_rank, jj)
            log('%d %d %f %s' % (ii, jj, value, str(q)))
            eij = value - numpy.dot(local_P[ii], q)
            local_P[ii] += alpha * (2 * eij * q - beta * local_P[ii])
        for row in local_data:
            ii = int(row[0] - local_data[0][0])
            jj = int(row[1] - 1)
            value = float(row[2])
            q = local_Q.get(jj)
            eij = value - numpy.dot(local_P[ii], q)
            client.inc(my_rank, jj, alpha * (2 * eij * local_P[ii] - beta * q))

        e = 0.0
        for row in local_data:
            ii = row[0] - local_data[0][0]
            jj = row[1] - 1
            value = row[2]
            if abs(value - 0.0) > 0.000001:
                e += pow(numpy.dot(local_P[ii], local_Q[jj]) - value, 2)
    client.stop(my_rank)
    MPI.Finalize()
    return
开发者ID:ay27,项目名称:MatrixFactorization,代码行数:44,代码来源:MF.py

示例2: main

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import stop [as 别名]
def main(topic):
    util.initLogs()
    client1 = Client(event_delay=1, topics=[topic], name='Stranger 1')
    client2 = Client(event_delay=1, topics=[topic], name='Stranger 2')
    client1.register_other_client(client2)
    client2.register_other_client(client1)

    client1.start()
    util.waitForClient(client1, topic)
    client2.start()

    while client1.isAlive() or client2.isAlive():
        try:
            client1.join(0.1)
            client2.join(0.1)
        except KeyboardInterrupt:
            break

    util.logPrint( 'Disconnecting... ')
    client1.stop()
    client2.stop()
开发者ID:lyenliang,项目名称:Omegle-MITM,代码行数:23,代码来源:OmegleMITM.py

示例3: Interface

# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import stop [as 别名]
class Interface():
	
	def __init__(self):
		self.initUI()
		self.state = State()
		self.client = Client(API_URL, self.update_state)
	
	def toggle(self):
		self.client.toggle()
		self.update_state()
	
	def stop(self):
		self.client.stop()
		self.update_state()
	
	def next(self):
		self.client.skip()
		self.update_state()
	
	def get_status(self):
		return self.state
	
	def update_state(self):
		self.state.playing = self.client.playing
		times = re.findall("[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", self.client.player.stderr)
		if len(times) == 2:
			self.state.play_time = self.state._string_to_secs(times[0])
			self.state.track_time = self.state._string_to_secs(times[1])
			self.state.time_string = times[0] + "/" + times[1]
		self.refresh()
	
	def cleanup(self):
		self.client.stop()
		self.client.clear_cache()
	
	def refresh(self):
		pass
	
	def initUI(self):
		pass
开发者ID:klaxa,项目名称:utagumo-client,代码行数:42,代码来源:Interface.py


注:本文中的Client.Client.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。