import socket
import threading
from dcs.tests.user_request_handler import Urh
from loguru import logger


class UP(threading.Thread):
    def __init__(self):
        super(UP, self).__init__()
        self.requests: list[tuple[socket.socket, dict]] = []

    def add_request(self, request_map: dict, client_socket: socket.socket):
        self.requests.append((client_socket, request_map))

    def run(self) -> None:
        while True:
            for request in self.requests:
                logger.info(f'processing user request...')
                urh = Urh(request[1], request[0])
                urh.start()
                self.requests.remove(request)
        pass
