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


Python Client._connect方法代码示例

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


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

示例1: test_socket_connect_unix

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
    def test_socket_connect_unix(self):
        server = '/tmp/pymemcache.{pid}'.format(pid=os.getpid())

        with MockUnixSocketServer(server):
            client = Client(server)
            client._connect()
            assert client.sock.family == socket.AF_UNIX
开发者ID:pinterest,项目名称:pymemcache,代码行数:9,代码来源:test_client.py

示例2: test_socket_close

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
    def test_socket_close(self):
        server = ("example.com", 11211)

        client = Client(server, socket_module=MockSocketModule())
        client._connect()
        assert client.sock is not None

        client.close()
        assert client.sock is None
开发者ID:pinterest,项目名称:pymemcache,代码行数:11,代码来源:test_client.py

示例3: test_socket_connect_closes_on_failure

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
    def test_socket_connect_closes_on_failure(self):
        server = ("example.com", 11211)

        socket_module = MockSocketModule(connect_failure=OSError())
        client = Client(server, socket_module=socket_module)
        with pytest.raises(OSError):
            client._connect()
        assert len(socket_module.sockets) == 1
        assert socket_module.sockets[0].connections == []
        assert socket_module.sockets[0].closed
开发者ID:Morreski,项目名称:pymemcache,代码行数:12,代码来源:test_client.py

示例4: test_socket_close_exception

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
    def test_socket_close_exception(self):
        server = ("example.com", 11211)

        socket_module = MockSocketModule(close_failure=OSError())
        client = Client(server, socket_module=socket_module)
        client._connect()
        assert client.sock is not None

        client.close()
        assert client.sock is None
开发者ID:pinterest,项目名称:pymemcache,代码行数:12,代码来源:test_client.py

示例5: test_socket_connect

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
    def test_socket_connect(self):
        server = ("example.com", 11211)

        client = Client(server, socket_module=MockSocketModule())
        client._connect()
        assert client.sock.connections == [server]

        timeout = 2
        connect_timeout = 3
        client = Client(
            server,
            connect_timeout=connect_timeout,
            timeout=timeout,
            socket_module=MockSocketModule(),
        )
        client._connect()
        assert client.sock.timeouts == [connect_timeout, timeout]

        client = Client(server, socket_module=MockSocketModule())
        client._connect()
        assert client.sock.socket_options == []

        client = Client(server, socket_module=MockSocketModule(), no_delay=True)
        client._connect()
        assert client.sock.socket_options == [
            (socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
        ]
开发者ID:Morreski,项目名称:pymemcache,代码行数:29,代码来源:test_client.py

示例6: make_client

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
 def make_client(self, mock_socket_values, **kwargs):
     client = Client(None, **kwargs)
     # mock out client._connect() rather than hard-settting client.sock to
     # ensure methods are checking whether self.sock is None before
     # attempting to use it
     sock = MockSocket(list(mock_socket_values))
     client._connect = mock.Mock(side_effect=functools.partial(
         setattr, client, "sock", sock))
     return client
开发者ID:pinterest,项目名称:pymemcache,代码行数:11,代码来源:test_client.py

示例7: test_socket_connect_unix

# 需要导入模块: from pymemcache.client.base import Client [as 别名]
# 或者: from pymemcache.client.base.Client import _connect [as 别名]
 def test_socket_connect_unix(self):
     server = "/tmp/memcache"
     with MockUnixSocket(server):
         client = Client(server)
         assert client._use_unix_socket
         client._connect()
开发者ID:Morreski,项目名称:pymemcache,代码行数:8,代码来源:test_client.py


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