本文整理匯總了Python中gnsq.Nsqd.ready_count方法的典型用法代碼示例。如果您正苦於以下問題:Python Nsqd.ready_count方法的具體用法?Python Nsqd.ready_count怎麽用?Python Nsqd.ready_count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnsq.Nsqd
的用法示例。
在下文中一共展示了Nsqd.ready_count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_random_ready_conn
# 需要導入模塊: from gnsq import Nsqd [as 別名]
# 或者: from gnsq.Nsqd import ready_count [as 別名]
def test_random_ready_conn():
conn_1 = Nsqd('nsq1')
conn_2 = Nsqd('nsq2')
reader = Reader('test', 'test', 'localhost:4150')
reader.max_in_flight = 2
reader.conns = [conn_2]
reader.last_random_ready = 0
assert reader.random_ready_conn(conn_1) is conn_1
assert reader.last_random_ready == 0
reader.max_in_flight = 1
reader.conns = [conn_2, conn_2]
reader.last_random_ready = last_random_ready = time.time()
assert reader.random_ready_conn(conn_1) is conn_1
assert reader.last_random_ready == last_random_ready
reader.max_in_flight = 1
reader.conns = [conn_2, conn_2]
reader.last_random_ready = 0
assert reader.random_ready_conn(conn_1) is conn_2
assert reader.last_random_ready != 0
reader.max_in_flight = 1
reader.conns = [conn_2, conn_2]
reader.last_random_ready = 0
conn_2.ready_count = 1
assert reader.random_ready_conn(conn_1) is conn_1
assert reader.last_random_ready == 0