当前位置: 首页>>代码示例>>Python>>正文


Python Server.stop方法代码示例

本文整理汇总了Python中kademlia.network.Server.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Server.stop方法的具体用法?Python Server.stop怎么用?Python Server.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kademlia.network.Server的用法示例。


在下文中一共展示了Server.stop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_custom_protocol

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
    def test_custom_protocol(self):
        """
        A subclass of Server which overrides the protocol_class attribute will
        have an instance of that class as its protocol after its listen()
        method is called.
        """

        # Make a custom Protocol and Server to go with hit.
        class CoconutProtocol(KademliaProtocol):
            pass

        class HuskServer(Server):
            protocol_class = CoconutProtocol

        # An ordinary server does NOT have a CoconutProtocol as its protocol...
        loop = asyncio.get_event_loop()
        server = Server()
        loop.run_until_complete(server.listen(8469))
        self.assertNotIsInstance(server.protocol, CoconutProtocol)
        server.stop()

        # ...but our custom server does.
        husk_server = HuskServer()
        loop.run_until_complete(husk_server.listen(8469))
        self.assertIsInstance(husk_server.protocol, CoconutProtocol)
        husk_server.stop()
开发者ID:bmuller,项目名称:kademlia,代码行数:28,代码来源:test_server.py

示例2: bootstrap_node

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
def bootstrap_node(event_loop):
    server = Server()
    event_loop.run_until_complete(server.listen(8468))

    try:
        yield ('127.0.0.1', 8468)
    finally:
        server.stop()
开发者ID:bmuller,项目名称:kademlia,代码行数:10,代码来源:conftest.py

示例3: test_storing

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
async def test_storing(bootstrap_node):
    server = Server()
    await server.listen(bootstrap_node[1] + 1)
    await server.bootstrap([bootstrap_node])
    await server.set('key', 'value')
    result = await server.get('key')

    assert result == 'value'

    server.stop()
开发者ID:bmuller,项目名称:kademlia,代码行数:12,代码来源:test_server.py

示例4: test_default_protocol

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
 def test_default_protocol(self):
     """
     An ordinary Server object will initially not have a protocol, but will
     have a KademliaProtocol object as its protocol after its listen()
     method is called.
     """
     server = Server()
     self.assertIsNone(server.protocol)
     server.listen(8469)
     self.assertIsInstance(server.protocol, KademliaProtocol)
     server.stop()
开发者ID:imnisen,项目名称:kademlia,代码行数:13,代码来源:test_server.py

示例5: test_default_protocol

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
 def test_default_protocol(self):
     """
     An ordinary Server object will initially not have a protocol, but will
     have a KademliaProtocol object as its protocol after its listen()
     method is called.
     """
     loop = asyncio.get_event_loop()
     server = Server()
     self.assertIsNone(server.protocol)
     loop.run_until_complete(server.listen(8469))
     self.assertIsInstance(server.protocol, KademliaProtocol)
     server.stop()
开发者ID:bmuller,项目名称:kademlia,代码行数:14,代码来源:test_server.py

示例6: Server

# 需要导入模块: from kademlia.network import Server [as 别名]
# 或者: from kademlia.network.Server import stop [as 别名]
import logging
import asyncio

from kademlia.network import Server

handler = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
log = logging.getLogger('kademlia')
log.addHandler(handler)
log.setLevel(logging.DEBUG)


loop = asyncio.get_event_loop()
loop.set_debug(True)

server = Server()
loop.run_until_complete(server.listen(8468))

try:
    loop.run_forever()
except KeyboardInterrupt:
    pass
finally:
    server.stop()
    loop.close()
开发者ID:bmuller,项目名称:kademlia,代码行数:28,代码来源:first_node.py


注:本文中的kademlia.network.Server.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。