本文整理汇总了Python中zeroless.Client.sub方法的典型用法代码示例。如果您正苦于以下问题:Python Client.sub方法的具体用法?Python Client.sub怎么用?Python Client.sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zeroless.Client
的用法示例。
在下文中一共展示了Client.sub方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subscribed_topics_are_not_bytes
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def test_subscribed_topics_are_not_bytes(self):
client = Client()
client.connect_local(port=7099)
client.sub(topics=[b'topic1'])
with pytest.raises(TypeError):
client.sub(topics=[u'topic1'])
with pytest.raises(TypeError):
client.sub(topics=[b'topic1', u'topic2'])
示例2: Client
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
from zeroless import Client
# Connects the client to as many servers as desired
client = Client()
client.connect_local(port=12345)
# Initiate a subscriber client
# Assigns an iterable to wait for incoming messages with any topic
listen_for_pub = client.sub()
for topic, id, msg in listen_for_pub:
print(topic, ' - ', id, ' - ', msg)
示例3: listen_for_pub
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def listen_for_pub():
client = Client()
client.connect_local(port=7893)
return client.sub()
示例4: listen_for_pub_with_empty_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def listen_for_pub_with_empty_topic():
client = Client()
client.connect(ip='127.0.0.1', port=7895)
return client.sub()
示例5: listen_for_pub_with_embedded_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def listen_for_pub_with_embedded_topic():
client = Client()
client.connect(ip='127.0.0.1', port=7894)
return client.sub(topics=[b'sh'])
示例6: import
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
import logging
from zeroless import (Client, log)
# Setup console logging
consoleHandler = logging.StreamHandler()
log.setLevel(logging.DEBUG)
log.addHandler(consoleHandler)
# Connects the client to as many servers as desired
client = Client()
client.connect_local(port=12345)
# Initiate a subscriber client
# Assigns an iterable to wait for incoming messages with the topic 'sh'
listen_for_pub = client.sub(topics=[b'sh'])
for topic, msg in listen_for_pub:
print(topic, ' - ', msg)
示例7: listen_for_pub_with_empty_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def listen_for_pub_with_empty_topic():
client = Client()
client.connect_local(port=7896)
return client.sub()
示例8: listen_for_pub_with_embedded_topic
# 需要导入模块: from zeroless import Client [as 别名]
# 或者: from zeroless.Client import sub [as 别名]
def listen_for_pub_with_embedded_topic():
client = Client()
client.connect_local(port=7894)
return client.sub(topics=[b'sh'])