es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: PYTHON-MULTITHREADING

¿Cómo puedo implementar el multihilo en este bucle for?

Considere este fragmento de código: from tqdm import trange def main_game(depth1, depth2): # algún operador con una complejidad de O(20^max(depth1,depth2)) return depth1+depth2 DEPTH_MAX = 5 total = 0 for depth1 in range(1, DEPTH_MAX + 1): for depth2 in range(1, DEPTH_MAX + 1): for i in trange(100): total += main_game(depth1, depth2) . . . Read more

No se puede agregar un botón en un hilo de PyQt5.

No entendí por qué este código no funciona. import sys from threading import Thread from PyQt5.QtCore import QSize, Qt from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle(“Mi App”) self.setFixedSize(QSize(400, 300)) Thread(target=self.AddButton).start() def AddButton(self): button = QPushButton(“Presióname”, self) print(“Ok”) app = QApplication(sys.argv) window = MainWindow() window.show() app.exec() . . . Read more

Python: Recorre un código con hilos de ejecución.

Tengo un código que lee un archivo, selecciona una línea al azar del archivo y luego la imprime con múltiples hilos. El problema es que cada vez que ingreso por ejemplo 2 hilos, utiliza los hilos y detiene el código. Quiero que recorra todas las líneas del archivo y luego . . . Read more