本文整理汇总了Python中Client.Client.join方法的典型用法代码示例。如果您正苦于以下问题:Python Client.join方法的具体用法?Python Client.join怎么用?Python Client.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.join方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import join [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()
示例2: active_count
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import join [as 别名]
K=50,
key='5678',
secret=(7, 21))
assert alice.successfully_finished is None
assert bob.successfully_finished is None
assert charlie.successfully_finished is None
server.start()
alice.start()
bob.start()
charlie.start()
killed = False
alice.join(timeout=30)
bob.join(timeout=30)
charlie.join(timeout=30)
server.finish()
server.join(timeout=30)
if active_count() > 1:
for t in enumerate():
if t != current_thread():
print t
t._Thread__stop()
sys.exit(1)
assert alice.successfully_finished is True
assert bob.successfully_finished is True
assert charlie.successfully_finished is True
示例3: generate_random_key
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import join [as 别名]
from Client import Client
from Server import Server
from TrustedServer import TrustedServer
from Utils import generate_random_key
id_for_alice = 'alice'
id_for_bob = 'bob'
key_for_alice = generate_random_key()
key_for_bob = generate_random_key()
trusted_server = TrustedServer(keys={id_for_alice: key_for_alice, id_for_bob: key_for_bob}, max_connections=10)
trusted_server.start()
server = Server(server_id=id_for_bob, server_key=key_for_bob, max_connections=10, trusted_server=trusted_server)
server.start()
client = Client(client_id=id_for_alice, client_key=key_for_alice, server=server, server_id=id_for_bob)
client.start()
client.join()
server.finish()
trusted_server.finish()
示例4: Server
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import join [as 别名]
server_id='bob')
bob = Server(name='bob',
g=g,
p=p,
input_queue=queue_to_server,
output_queue=queue_to_client,
rsa_obj=rsa_bob,
keys=keys,
client_id='alice')
assert alice.K is None
assert bob.K is None
assert alice.finished_successfully is None
assert bob.finished_successfully is None
alice.start()
bob.start()
alice.join(timeout=50)
bob.join(timeout=50)
killed = False
if alice.is_alive():
alice._Thread__stop()
killed = True
if bob.is_alive():
bob._Thread__stop()
killed = True
if killed:
sys.exit(1)
assert alice.finished_successfully is True
assert bob.finished_successfully is True
assert alice.K == bob.K
示例5: active_count
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import join [as 别名]
assert bob.successfully_finished is None
assert charlie.successfully_finished is None
assert edvard.successfully_finished is None
assert david.successfully_finished is None
server.start()
alice.start()
bob.start()
charlie.start()
david.start()
edvard.start()
killed = False
timeout = 300
alice.join(timeout=timeout)
bob.join(timeout=timeout)
charlie.join(timeout=timeout)
edvard.join(timeout=timeout)
david.join(timeout=timeout)
server.finish()
server.join(timeout=timeout)
if active_count() > 1:
for t in threading.enumerate():
if t != current_thread():
print t
t._Thread__stop()
sys.exit(1)
assert alice.successfully_finished is True