def METHOD_NAME(self, connection, request):
    if request.destination[1] == CIRCUIT_ID_PORT:
        circuit = self.tunnels.circuits.get(self.tunnels.ip_to_circuit_id(request.destination[0]))
        if circuit and circuit.state == CIRCUIT_STATE_READY and circuit.ctype in [CIRCUIT_TYPE_RP_DOWNLOADER,
                                                                                  CIRCUIT_TYPE_RP_SEEDER]:
            return circuit
    hops = self.socks_servers.index(connection.socksserver) + 1
    options = [c for c in self.tunnels.circuits.values()
               if c.goal_hops == hops and c.state == CIRCUIT_STATE_READY and c.ctype == CIRCUIT_TYPE_DATA
               and self.cid_to_con.get(c.circuit_id, connection) == connection]
    if not options:
        # We allow each connection to claim at least 1 circuit. If no such circuit exists we'll create one.
        if connection in self.cid_to_con.values():
            self._logger.debug("No circuit for sending data to %s", request.destination)
            return None
        circuit = self.tunnels.create_circuit(goal_hops=hops)
        if circuit is None:
            self._logger.debug("Failed to create circuit for data to %s", request.destination)
            return None
        self._logger.debug("Creating circuit for data to %s. Retrying later..", request.destination)
        self.cid_to_con[circuit.circuit_id] = connection
        circuit.ready.add_done_callback(lambda f, c=connection.udp_connection, r=request:
                                        self.on_socks5_udp_data(c, r) if f.result() else None)
        return None
    circuit = random.choice(options)
    self.cid_to_con[circuit.circuit_id] = connection
    self.con_to_cir[connection][request.destination] = circuit
    self._logger.debug("Select circuit %d for %s", circuit.circuit_id, request.destination)
    return circuit