本文整理汇总了Python中mqttcli.MqttClient.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python MqttClient.destroy方法的具体用法?Python MqttClient.destroy怎么用?Python MqttClient.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mqttcli.MqttClient
的用法示例。
在下文中一共展示了MqttClient.destroy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_002
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import destroy [as 别名]
def test_002(self):
sub = MqttClient("sub:{seq}", connect=4)
sub.subscribe("foo/bar", qos=1)
pub = MqttClient("pub:{seq}", connect=4)
pub.publish("foo/bar", env.gen_msg(42), qos=1)
evt = sub.recv()
if not isinstance(evt, EventPublish):
debug(evt)
defer.returnValue(False)
# PUBACK not send
sub.destroy(); del sub
if (yield supervisor.count('wave_msgworkers_sup')) != 1:
debug("wrong msgworkers count")
defer.returnValue(False)
# msg worker is destroyed after 5 secs
time.sleep(6)
if (yield supervisor.count('wave_msgworkers_sup')) != 0:
debug("wrong msgworkers count")
defer.returnValue(False)
pub.disconnect()
defer.returnValue(True)
示例2: test_005
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import destroy [as 别名]
def test_005(self):
sub = MqttClient("sub:{seq}", connect=4)
sub.subscribe('a/b', qos=1)
pub = MqttClient("pub:{seq}", connect=4)
msg = gen_msg()
pub.publish('a/b', payload=msg, qos=1)
# destoying socket
pub.destroy(); del pub
e = sub.recv()
if not isinstance(e, EventPublish) or \
e.msg.payload != msg or \
e.msg.qos != 1:
debug('failing event: {0}'.format(e))
return False
sub.disconnect()
return True
示例3: test_001
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import destroy [as 别名]
def test_001(self):
sub = MqttClient("sub:{seq}", connect=4)
sub.subscribe("foo/bar", qos=0)
pub = MqttClient("pub:{seq}", connect=4)
pub.publish("foo/bar", env.gen_msg(42), qos=2)
# PUBREL not sent
pub.destroy(); del pub
cnt = yield supervisor.count('wave_msgworkers_sup')
if cnt != 1:
debug("wrong msgworkers count: {0}".format(cnt))
defer.returnValue(False)
# msg worker is destroyed after 5 secs
time.sleep(6)
if (yield supervisor.count('wave_msgworkers_sup')) != 0:
debug("wrong msgworkers count")
defer.returnValue(False)
defer.returnValue(True)
示例4: test_003
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import destroy [as 别名]
def test_003(self):
sub = MqttClient("sub:{seq}", connect=4)
sub.subscribe("foo/bar", qos=1)
sub2 = MqttClient("sub:{seq}", connect=4)
sub2.subscribe("foo/+", qos=1)
pub = MqttClient("pub:{seq}", connect=4)
pub.publish("foo/bar", env.gen_msg(42), qos=1)
evt1 = sub.recv()
evt2 = sub2.recv()
sub.destroy(); del sub
if (yield supervisor.count('wave_msgworkers_sup')) != 1:
debug("wrong msgworkers count")
defer.returnValue(False)
# sub removed, sub2 still alive
time.sleep(6)
if (yield supervisor.count('wave_msgworkers_sup')) != 1:
debug("wrong msgworkers count")
defer.returnValue(False)
# sub2 still alive
time.sleep(6)
if (yield supervisor.count('wave_msgworkers_sup')) != 1:
debug("wrong msgworkers count")
defer.returnValue(False)
# msg worker is destroyed after 5 secs
sub2.puback(evt2.msg.mid)
if (yield supervisor.count('wave_msgworkers_sup')) != 0:
debug("wrong msgworkers count")
defer.returnValue(False)
pub.disconnect()
defer.returnValue(True)
示例5: test_004
# 需要导入模块: from mqttcli import MqttClient [as 别名]
# 或者: from mqttcli.MqttClient import destroy [as 别名]
def test_004(self):
pub = MqttClient("pub:{seq}", connect=4)
pub.publish('a/b', payload=gen_msg(), qos=1)
pub.destroy(); del pub # socket destroyed
return True