本文整理汇总了Python中zeroless.Client类的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_data_is_not_bytes
def test_data_is_not_bytes(self):
client = Client()
client.connect_local(port=7050)
push = client.push()
with pytest.raises(TypeError):
push(u'msg')
示例2: test_client_addresses_property
def test_client_addresses_property(self):
client = Client()
addresses = (('10.0.0.1', 1567), ('10.0.0.2', 1568), ('10.0.0.3', 1569))
for ip, port in addresses:
client.connect(ip, port)
assert client.addresses == addresses
示例3: test_port_under_range
def test_port_under_range(self):
client = Client()
with pytest.raises(ValueError):
client.connect_local(port=1023)
with pytest.raises(ValueError):
client.disconnect_local(port=1023)
with pytest.raises(ValueError):
Server(port=1023)
示例4: test_connection_already_exist
def test_connection_already_exist(self):
client = Client()
client.connect_local(port=1024)
with pytest.raises(ValueError):
client.connect_local(port=1024)
client.disconnect_local(port=1024)
client.connect_local(port=1024)
示例5: test_connection_after_pattern_was_established
def test_connection_after_pattern_was_established(self):
client = Client()
listen_for_push = client.pull()
client.connect_local(port=1024)
with pytest.raises(ValueError):
client.connect_local(port=1024)
client.disconnect_local(port=1024)
with pytest.raises(ValueError):
client.disconnect_local(port=1024)
示例6: test_subscribed_topics_are_not_bytes
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'])
示例7: test_there_was_no_connection_to_disconnect
def test_there_was_no_connection_to_disconnect(self):
client = Client()
client.connect_local(port=1024)
with pytest.raises(ValueError):
client.disconnect_local(port=1025)
client.disconnect_local(port=1024)
with pytest.raises(ValueError):
client.disconnect_local(port=1024)
示例8: test_port_on_range
def test_port_on_range(self):
client = Client()
client.connect_local(port=1024)
client.disconnect_local(port=1024)
client.connect_local(port=7000)
client.disconnect_local(port=7000)
client.connect_local(port=65535)
client.disconnect_local(port=65535)
示例9: test_pair_client_cannot_connect_more_than_once
def test_pair_client_cannot_connect_more_than_once(self):
client = Client()
client.connect_local(port=7200)
client.connect_local(port=7201)
with pytest.raises(RuntimeError):
client.pair()
client = Client()
client.connect_local(port=7200)
client.pair()
with pytest.raises(RuntimeError):
client.connect_local(port=7201)
示例10: import
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 push client
# And assigns a callable to push messages
push = client.push()
for msg in [b"Msg1", b"Msg2", b"Msg3"]:
push(msg)
示例11: import
from zeroless import (Client, Server)
import json
from aura.managers import SemanticManager as graph
from aura.managers import StorageManager as db
from aura.managers import helpers
zmq_device = Client()
zmq_device.connect_local(port=helpers.ports['device_manager'])
push_to_device = zmq_device.push()
def create_condition(condition):
print("create_condition")
# TaskManager -> StorageManager
db.store('conditions', condition)
def update_condition():
# TaskManager -> StorageManager
print("update_condition")
def remove_condition():
# TaskManager -> StorageManager
print("remove_condition")
def send_command(device, command):
# TaskManager -> DeviceManager
print("send_command")
示例12: listen_for_pub_with_empty_topic
def listen_for_pub_with_empty_topic():
client = Client()
client.connect_local(port=7896)
return client.sub()
示例13: import
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)
示例14: import
import logging
from zeroless import (Client, log)
# Setup console logging
consoleHandler = logging.StreamHandler()
log.setLevel(logging.DEBUG)
log.addHandler(consoleHandler)
# Connects the client to a single server
client = Client()
client.connect_local(port=12345)
# Initiate a pair client
# And assigns a callable and an iterable
# To both transmit and wait for incoming messages
pair, listen_for_pair = client.pair()
for msg in [b"Msg1", b"Msg2", b"Msg3"]:
pair(msg)
response = next(listen_for_pair)
print(response)
示例15: pair
def pair():
client = Client()
client.connect_local(port=7890)
send, _ = client.pair()
return send