本文整理汇总了Python中pypeman.channels.BaseChannel.stop方法的典型用法代码示例。如果您正苦于以下问题:Python BaseChannel.stop方法的具体用法?Python BaseChannel.stop怎么用?Python BaseChannel.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypeman.channels.BaseChannel
的用法示例。
在下文中一共展示了BaseChannel.stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_channel_events
# 需要导入模块: from pypeman.channels import BaseChannel [as 别名]
# 或者: from pypeman.channels.BaseChannel import stop [as 别名]
def test_channel_events(self):
""" Whether BaseChannel handling return a good result """
chan = BaseChannel(name="test_channel7.5", loop=self.loop)
msg = generate_msg()
chan.add(nodes.JsonToPython(), nodes.PythonToJson())
state_sequence = [chan.status]
@events.channel_change_state.receiver
def handle_change_state(channel=None, old_state=None, new_state=None):
print(channel.name, old_state, new_state)
state_sequence.append(new_state)
@events.channel_change_state.receiver
async def handle_change_state_async(channel=None, old_state=None, new_state=None):
print(channel.name, old_state, new_state)
# Launch channel processing
self.start_channels()
self.loop.run_until_complete(chan.handle(msg))
self.loop.run_until_complete(chan.stop())
print(state_sequence)
valid_sequence = [BaseChannel.STOPPED, BaseChannel.STARTING, BaseChannel.WAITING,
BaseChannel.PROCESSING, BaseChannel.WAITING, BaseChannel.STOPPING, BaseChannel.STOPPED]
self.assertEqual(state_sequence, valid_sequence, "Sequence state is not valid")
示例2: test_channel_stopped_dont_process_message
# 需要导入模块: from pypeman.channels import BaseChannel [as 别名]
# 或者: from pypeman.channels.BaseChannel import stop [as 别名]
def test_channel_stopped_dont_process_message(self):
""" Whether BaseChannel handling return a good result """
chan = BaseChannel(name="test_channel7.7", loop=self.loop)
msg = generate_msg()
chan.add(nodes.JsonToPython(), nodes.PythonToJson())
# Launch channel processing
self.start_channels()
self.loop.run_until_complete(chan.handle(msg))
self.loop.run_until_complete(chan.stop())
with self.assertRaises(channels.ChannelStopped) as cm:
self.loop.run_until_complete(chan.handle(msg))