本文整理汇总了Python中pubnub.pubnub_asyncio.PubNubAsyncio.stop方法的典型用法代码示例。如果您正苦于以下问题:Python PubNubAsyncio.stop方法的具体用法?Python PubNubAsyncio.stop怎么用?Python PubNubAsyncio.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pubnub.pubnub_asyncio.PubNubAsyncio
的用法示例。
在下文中一共展示了PubNubAsyncio.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multiple_channels
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_multiple_channels(event_loop, sleeper=asyncio.sleep):
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
ch1 = 'test-where-now-asyncio-ch1'
ch2 = 'test-where-now-asyncio-ch2'
uuid = 'test-where-now-asyncio-uuid'
pubnub.config.uuid = uuid
callback = VCR599Listener(1)
pubnub.add_listener(callback)
pubnub.subscribe().channels([ch1, ch2]).execute()
yield from callback.wait_for_connect()
yield from sleeper(7)
env = yield from pubnub.where_now() \
.uuid(uuid) \
.future()
channels = env.result.channels
assert len(channels) == 2
assert ch1 in channels
assert ch2 in channels
pubnub.unsubscribe().channels([ch1, ch2]).execute()
yield from callback.wait_for_disconnect()
pubnub.stop()
示例2: test_subscribe_unsubscribe
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_subscribe_unsubscribe(event_loop):
channel = "test-subscribe-asyncio-ch"
pubnub = PubNubAsyncio(pnconf_sub_copy(), custom_event_loop=event_loop)
callback = SubscribeListener()
pubnub.add_listener(callback)
pubnub.subscribe().channels(channel).execute()
assert channel in pubnub.get_subscribed_channels()
assert len(pubnub.get_subscribed_channels()) == 1
yield from callback.wait_for_connect()
assert channel in pubnub.get_subscribed_channels()
assert len(pubnub.get_subscribed_channels()) == 1
pubnub.unsubscribe().channels(channel).execute()
assert channel not in pubnub.get_subscribed_channels()
assert len(pubnub.get_subscribed_channels()) == 0
yield from callback.wait_for_disconnect()
assert channel not in pubnub.get_subscribed_channels()
assert len(pubnub.get_subscribed_channels()) == 0
pubnub.stop()
示例3: test_add_channel_remove_group
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_add_channel_remove_group(event_loop, sleeper=asyncio.sleep):
pubnub = PubNubAsyncio(pnconf, custom_event_loop=event_loop)
ch = "channel-groups-tornado-ch"
gr = "channel-groups-tornado-cg"
# add
env = yield from pubnub.add_channel_to_channel_group() \
.channels(ch).channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsAddChannelResult)
yield from sleeper(1)
# list
env = yield from pubnub.list_channels_in_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsListResult)
assert len(env.result.channels) == 1
assert env.result.channels[0] == ch
# remove group
env = yield from pubnub.remove_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsRemoveGroupResult)
yield from sleeper(1)
# list
env = yield from pubnub.list_channels_in_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsListResult)
assert len(env.result.channels) == 0
pubnub.stop()
示例4: test_single_channel_group
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_single_channel_group(event_loop):
pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
pubnub.config.uuid = "test-pam-asyncio-uuid"
cg = "test-pam-asyncio-cg"
env = (yield from pubnub.grant()
.channel_groups(cg)
.write(True)
.read(True)
.future())
assert isinstance(env.result, PNAccessManagerGrantResult)
assert env.result.level == 'channel-group'
assert env.result.groups[cg].read_enabled == 1
assert env.result.groups[cg].write_enabled == 1
assert env.result.groups[cg].manage_enabled == 0
env = (yield from pubnub.audit()
.channel_groups(cg)
.future())
assert isinstance(env.result, PNAccessManagerAuditResult)
assert env.result.level == 'channel-group'
assert env.result.groups[cg].read_enabled == 1
assert env.result.groups[cg].write_enabled == 1
assert env.result.groups[cg].manage_enabled == 0
pubnub.stop()
示例5: test_super_call
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_super_call(event_loop):
pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
ch = "channel-groups-torna|do-ch"
gr = "channel-groups-torna|do-cg"
pubnub.config.auth = "h.e|l%l,0"
# add
env = yield from pubnub.add_channel_to_channel_group() \
.channels(ch).channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsAddChannelResult)
# list
env = yield from pubnub.list_channels_in_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsListResult)
# remove channel
env = yield from pubnub.remove_channel_from_channel_group().channel_group(gr).channels(ch).future()
assert isinstance(env.result, PNChannelGroupsRemoveChannelResult)
# remove group
env = yield from pubnub.remove_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsRemoveGroupResult)
# list
env = yield from pubnub.list_channels_in_channel_group().channel_group(gr).future()
assert isinstance(env.result, PNChannelGroupsListResult)
pubnub.stop()
示例6: test_multiple_channels
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_multiple_channels(event_loop):
pubnub = PubNubAsyncio(pnconf, custom_event_loop=event_loop)
ch1 = 'test-state-asyncio-ch1'
ch2 = 'test-state-asyncio-ch2'
pubnub.config.uuid = 'test-state-asyncio-uuid'
state = {"name": "Alex", "count": 5}
env = yield from pubnub.set_state() \
.channels([ch1, ch2]) \
.state(state) \
.future()
assert env.result.state['name'] == "Alex"
assert env.result.state['count'] == 5
env = yield from pubnub.get_state() \
.channels([ch1, ch2]) \
.future()
assert env.result.channels[ch1]['name'] == "Alex"
assert env.result.channels[ch2]['name'] == "Alex"
assert env.result.channels[ch1]['count'] == 5
assert env.result.channels[ch2]['count'] == 5
pubnub.stop()
示例7: test_publish_envelope
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_publish_envelope(event_loop):
pubnub = PubNubAsyncio(pnconf_copy(), custom_event_loop=event_loop)
envelope = yield from pubnub.publish().message('hey').channel('blah').future()
assert isinstance(envelope, AsyncioEnvelope)
assert not envelope.is_error()
pubnub.stop()
示例8: test_not_permitted
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_not_permitted(event_loop):
pnconf = pnconf_pam_copy()
pnconf.secret_key = None
pubnub = PubNubAsyncio(pnconf, custom_event_loop=event_loop)
yield from assert_server_side_error_yield(pubnub.publish().channel(ch).message("hey"), "HTTP Client Error (403")
pubnub.stop()
示例9: test_single_channel_with_auth
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_single_channel_with_auth(event_loop):
pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
pubnub.config.uuid = "test-pam-asyncio-uuid"
ch = "test-pam-asyncio-ch"
auth = "test-pam-asyncio-auth"
env = (yield from pubnub.grant()
.channels(ch)
.write(True)
.read(True)
.auth_keys(auth)
.future())
assert isinstance(env.result, PNAccessManagerGrantResult)
assert env.result.channels[ch].auth_keys[auth].read_enabled == 1
assert env.result.channels[ch].auth_keys[auth].write_enabled == 1
assert env.result.channels[ch].auth_keys[auth].manage_enabled == 0
env = (yield from pubnub.audit()
.channels(ch)
.auth_keys(auth)
.future())
assert isinstance(env.result, PNAccessManagerAuditResult)
assert env.result.channels[ch].auth_keys[auth].read_enabled == 1
assert env.result.channels[ch].auth_keys[auth].write_enabled == 1
assert env.result.channels[ch].auth_keys[auth].manage_enabled == 0
pubnub.stop()
示例10: test_single_channel_with_subscription
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_single_channel_with_subscription(event_loop, sleeper=asyncio.sleep):
pnconf = pnconf_sub_copy()
pnconf.set_presence_timeout(12)
pubnub = PubNubAsyncio(pnconf, custom_event_loop=event_loop)
ch = "test-state-asyncio-ch"
pubnub.config.uuid = "test-state-asyncio-uuid"
state = {"name": "Alex", "count": 5}
callback = VCR599Listener(1)
pubnub.add_listener(callback)
pubnub.subscribe().channels(ch).execute()
yield from callback.wait_for_connect()
yield from sleeper(20)
env = yield from pubnub.set_state().channels(ch).state(state).future()
assert env.result.state["name"] == "Alex"
assert env.result.state["count"] == 5
env = yield from pubnub.get_state().channels(ch).future()
assert env.result.channels[ch]["name"] == "Alex"
assert env.result.channels[ch]["count"] == 5
pubnub.unsubscribe().channels(ch).execute()
yield from callback.wait_for_disconnect()
pubnub.stop()
示例11: test_multiple_channel_groups_with_auth
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_multiple_channel_groups_with_auth(event_loop):
pubnub = PubNubAsyncio(pnconf_pam_copy(), custom_event_loop=event_loop)
pubnub.config.uuid = "my_uuid"
gr1 = "test-pam-asyncio-cg1"
gr2 = "test-pam-asyncio-cg2"
auth = "test-pam-asyncio-auth"
env = (yield from pubnub.grant()
.channel_groups([gr1, gr2])
.write(True)
.read(True)
.auth_keys(auth)
.future())
assert isinstance(env.result, PNAccessManagerGrantResult)
assert env.result.groups[gr1].auth_keys[auth].read_enabled is True
assert env.result.groups[gr2].auth_keys[auth].read_enabled is True
assert env.result.groups[gr1].auth_keys[auth].write_enabled is True
assert env.result.groups[gr2].auth_keys[auth].write_enabled is True
assert env.result.groups[gr1].auth_keys[auth].manage_enabled is False
assert env.result.groups[gr2].auth_keys[auth].manage_enabled is False
env = (yield from pubnub.audit()
.channel_groups([gr1, gr2])
.future())
assert isinstance(env.result, PNAccessManagerAuditResult)
assert env.result.groups[gr1].auth_keys[auth].read_enabled is True
assert env.result.groups[gr2].auth_keys[auth].read_enabled is True
assert env.result.groups[gr1].auth_keys[auth].write_enabled is True
assert env.result.groups[gr2].auth_keys[auth].write_enabled is True
assert env.result.groups[gr1].auth_keys[auth].manage_enabled is False
assert env.result.groups[gr2].auth_keys[auth].manage_enabled is False
pubnub.stop()
示例12: test_publish_envelope_raises
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_publish_envelope_raises(event_loop):
pubnub = PubNubAsyncio(corrupted_keys, custom_event_loop=event_loop)
e = yield from pubnub.publish().message('hey').channel('blah').future()
assert isinstance(e, PubNubAsyncioException)
assert e.is_error()
assert 400 == e.value()._status_code
pubnub.stop()
示例13: test_error_non_serializable
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_error_non_serializable(event_loop):
pubnub = PubNubAsyncio(pnconf_copy(), custom_event_loop=event_loop)
def method():
pass
yield from assert_client_side_error(pubnub.publish().channel(ch).message(method), "not JSON serializable")
pubnub.stop()
示例14: test_timeout_event_on_broken_heartbeat
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_timeout_event_on_broken_heartbeat(event_loop):
ch = helper.gen_channel("heartbeat-test")
pubnub = PubNubAsyncio(messenger_config, custom_event_loop=event_loop)
pubnub_listener = PubNubAsyncio(listener_config, custom_event_loop=event_loop)
pubnub.config.uuid = helper.gen_channel("messenger")
pubnub_listener.config.uuid = helper.gen_channel("listener")
# - connect to :ch-pnpres
callback_presence = SubscribeListener()
pubnub_listener.add_listener(callback_presence)
pubnub_listener.subscribe().channels(ch).with_presence().execute()
yield from callback_presence.wait_for_connect()
envelope = yield from callback_presence.wait_for_presence_on(ch)
assert ch == envelope.channel
assert 'join' == envelope.event
assert pubnub_listener.uuid == envelope.uuid
# - connect to :ch
callback_messages = SubscribeListener()
pubnub.add_listener(callback_messages)
pubnub.subscribe().channels(ch).execute()
useless_connect_future = callback_messages.wait_for_connect()
presence_future = asyncio.ensure_future(callback_presence.wait_for_presence_on(ch))
# - assert join event
yield from asyncio.wait([useless_connect_future, presence_future])
prs_envelope = presence_future.result()
assert ch == prs_envelope.channel
assert 'join' == prs_envelope.event
assert pubnub.uuid == prs_envelope.uuid
# wait for one heartbeat call
yield from asyncio.sleep(8)
# - break messenger heartbeat loop
pubnub._subscription_manager._stop_heartbeat_timer()
# - assert for timeout
envelope = yield from callback_presence.wait_for_presence_on(ch)
assert ch == envelope.channel
assert 'timeout' == envelope.event
assert pubnub.uuid == envelope.uuid
pubnub.unsubscribe().channels(ch).execute()
yield from callback_messages.wait_for_disconnect()
# - disconnect from :ch-pnpres
pubnub_listener.unsubscribe().channels(ch).execute()
yield from callback_presence.wait_for_disconnect()
pubnub.stop()
pubnub_listener.stop()
示例15: test_publish_mixed_via_post
# 需要导入模块: from pubnub.pubnub_asyncio import PubNubAsyncio [as 别名]
# 或者: from pubnub.pubnub_asyncio.PubNubAsyncio import stop [as 别名]
def test_publish_mixed_via_post(event_loop):
pubnub = PubNubAsyncio(pnconf_copy(), custom_event_loop=event_loop)
yield from asyncio.gather(
asyncio.ensure_future(assert_success_publish_post(pubnub, "hi")),
asyncio.ensure_future(assert_success_publish_post(pubnub, 5)),
asyncio.ensure_future(assert_success_publish_post(pubnub, True)),
asyncio.ensure_future(assert_success_publish_post(pubnub, ["hi", "hi2", "hi3"])))
pubnub.stop()