Tag: PYTHON-MULTITHREADING
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 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
Al principio, no tengo errores ni bugs, hago esta pregunta para comprender más. Quiero enviar varios archivos simultáneamente a un servidor desde un cliente utilizando una conexión separada. Utilicé hilos para hacer que el proceso de envío sea simultáneo en el lado del cliente. Parece que mejora un poco el . . . Read more
Por supuesto, echaré un vistazo a Python multiprocessing con “pool” para resolver eso, pero me pregunto por qué NumPy actúa de esa manera. En el mejor de los casos, puedo ver lo siguiente: 1 core al 100% 2 cores alrededor del 70% 3 cores alrededor del 5% Con programas similares . . . Read more
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