Example #1
0
def http_coroutine(client_sock):
    while True:
        try:
            request = client_sock.recv(512)
            # metrics
            start_time = time.time()

            if request:
                client_sock.sendall(response.random_uuids())

                # metrics
                count_request()
                time_request(time.time() - start_time)
            else:
                break
        except:
            break
    client_sock.close()
Example #2
0
def handle_client_read(s):
    try:
        request = s.recv(512)
        # metrics
        start_time = time.time()

        if request:
            s.sendall(response.random_uuids())

            # metrics
            count_request()
            time_request(time.time() - start_time)
        else:
            s.close()
            read_list.remove(s)
    except:
        s.close()
        read_list.remove(s)
def http_thread(client_sock):
    while True:
        try:
            request = client_sock.recv(512)
            # metrics
            start_time = time.time()

            if request:
                client_sock.sendall(response.image_payload)

                # metrics
                count_request()
                time_request(time.time() - start_time)
            else:
                break
        except:
            break
    client_sock.close()