本文整理汇总了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
示例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
示例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
示例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
示例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)
]
示例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
示例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()