def test_allows_passing_host_port_and_timeout(self): with closing( connection.SerfConnection(host='foo', port=455, timeout=500)) as rpc: assert rpc.host == 'foo' assert rpc.port == 455 assert rpc.timeout == 500
def test_connection_to_bad_socket_throws_exception(self): with closing(connection.SerfConnection(port=40000)) as rpc: with pytest.raises( connection.SerfConnectionError) as exceptionInfo: rpc.handshake() assert 'connecting localhost:40000. Connection refused.' \ in str(exceptionInfo)
def rpc(self): return connection.SerfConnection()
import json from serfclient import connection from serfclient.client import SerfClient client = SerfClient() con = connection.SerfConnection() con.handshake() result = con.call('members') def get_members(): return result.body.get('Members')
def rpc(self): with closing(connection.SerfConnection()) as conn: yield conn