本文整理匯總了Python中gnsq.Nsqd.multipublish方法的典型用法代碼示例。如果您正苦於以下問題:Python Nsqd.multipublish方法的具體用法?Python Nsqd.multipublish怎麽用?Python Nsqd.multipublish使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnsq.Nsqd
的用法示例。
在下文中一共展示了Nsqd.multipublish方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_multipublish
# 需要導入模塊: from gnsq import Nsqd [as 別名]
# 或者: from gnsq.Nsqd import multipublish [as 別名]
def test_multipublish():
@mock_server
def handle(socket, address):
assert socket.recv(4) == ' V2'
assert socket.recv(11) == 'MPUB topic\n'
size = nsq.unpack_size(socket.recv(4))
data = socket.recv(size)
head, data = data[:4], data[4:]
assert nsq.unpack_size(head) == 2
for _ in xrange(2):
head, data = data[:4], data[4:]
assert nsq.unpack_size(head) == 3
head, data = data[:3], data[3:]
assert head == 'sup'
assert data == ''
with handle as server:
conn = Nsqd(address='127.0.0.1', tcp_port=server.server_port)
conn.connect()
conn.multipublish('topic', ['sup', 'sup'])