def test_creating_with_host_port_pair_str(self, host_config): client = GearmanAdminClient(host_list=[host_config]) assert len(client.connection_list) == 1 _assert_gearman_connection_equal(conn1=GearmanConnection( host="localhost", port=4730), conn2=client.connection_list[0])
def set_job_servers(self, servers, pre_connect=False): # TODO: don't shut down dups. shut down old ones gracefully self.connections = [] self.connections_by_hostport = {} for serv in servers: connection = GearmanConnection(serv, timeout=2) if pre_connect: try: connection.connect() except connection.ConnectionError: pass self.connections.append(connection) self.connections_by_hostport[connection.hostspec] = connection
def start_server(self): self.server_pid = os.fork() if not self.server_pid: server = GearmanServer() server.start() sys.exit() connection = GearmanConnection(job_servers[0]) for i in range(10): try: connection.connect() except GearmanConnection.ConnectionError: time.sleep(0.5) else: break connection.close()
def test_creating_with_ssl_host(self): host_config = { "host": "localhost", "port": 5000, "keyfile": "key.txt", "certfile": "cert.txt", "ca_certs": "ca_certs.txt", } client = GearmanAdminClient(host_list=[host_config]) assert len(client.connection_list) == 1 _assert_gearman_connection_equal(conn1=GearmanConnection( host="localhost", port=5000, keyfile="key.txt", certfile="cert.txt", ca_certs="ca_certs.txt"), conn2=client.connection_list[0])
def setUp(self): self.start_server() self.connection = GearmanConnection(job_servers[0]) self.connection.connect()